#include "inc/hw_memmap.h"
#include "wdt_a.h"
#include "ucs.h"
#include "usci_uart.h"
#include "gpio.h"
#include "pmm.h"
#include "SIadc.h"
#include "h1010.h"
#include "DataType.h"
#include "SI.h"
#include "SI_NS.h"
#include "SOSZ.h"
#include "Serial.h"
#include "main.h"
#include "ConfigMem.h"
#include "I2C_IO_Driver.h"
#include "LED.h"
#include "Fault.h"
#include "Relay.h"
#include "Button.h"
#include "GA.h"
#include "FWS.h"
#include "Buzzer.h"
#include "Test.h"
#include "String.h"

#include <string.h>

#if ENABLE_DEBUG_SERIAL_UART
	unsigned int baseAddress = USCI_A1_BASE;
#else
	unsigned int baseAddress = USCI_A0_BASE;
#endif

#define GA_TIMER_PRE_ALERT_0 	0
#define GA_TIMER_PRE_ALERT_10 	10
#define GA_TIMER_ALERT_0 		0
#define GA_TIMER_ALERT_10 		10
#define GA_TIMER_ALERT_12 		12
#define GA_TIMER_ALERT_ON_0 	0
#define GA_TIMER_ALERT_ON_2 	2
#define GA_TIMER_ALERT_OFF_0 	0
#define GA_TIMER_ALERT_OFF_2 	2
#define GA_TIMER_EVAC_MIN_0 	0
#define GA_TIMER_EVAC_MIN_10 	10
#define GA_TIMER_AUTO_SILENCE_0 0
#define GA_TIMER_AUTO_SILENCE_2 2
#define GA_TIMER_AUTO_SILENCE_10 10
#define GA_TIMER_10 10
#define GA_TIMER_0 0

unsigned char test_msg[20];
unsigned char test_msg_position = 0;
enum DebugStatus debugStatus = DEBUG_DISABLED;

//*****************************************************************************
//Select Baud rate
//*****************************************************************************
#define BAUD_RATE                               19200//9600

struct Test_GA_result_t {
	WORD gaTestNumber;
//	enum SI_STATE siStateFinal;
	enum eGA_OutputStatus gaOutputStatus;
	enum eGA_silence gaSilence;
	enum eGA_States gaState;
//	enum SO_objectType soObjectType;
//	enum SO_objectNumber soObjectNum;
//	BYTE soszTriggerValue;
//	enum Enabled_state soEnabledState;
	enum RATES gaSilenceLedRate;
};
enum Test_GA_id {
	stNorm_gaOff_notSil_ledOff=0,
	stNorm_gaOn_notSil_ledOff=4,
	stEvac_gaOn_notSil_ledOff=1,
	stEvac_gaOff_isSil_ledOn=2,
	stPreAlert_gaOn_notSil_ledOff=18,
	stPreAlert_gaOff_notSil_ledOff=10,
	stAlert_gaOn_notSil_ledOff=12,
	stAlert_gaOff_notSil_ledOff=13,
	stAlert_gaOff_isSil_ledOn=19,
	stEvacInhSil_gaOn_notSil_ledOff = 20,
	stEvacAutoSil_gaOn_notSil_ledOff = 21,
	stEvacAutoSil_gaOff_isSil_ledOn = 22
};
struct Test_GA_result_t gaTestResultTable [] = {
/* tstNum, siStateFinal, 		gaOutputStatus,  gaSilence,   gaState, soObjectType, soObjectNum, soszTriggerValue, soEnabledState, gaSilenceLedRate;*/
{0, GA_STATUS_OFF, 	NOT_SILENCED, GA_NORMAL, 		RATE_OFF},  // test after init
{1, GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 		RATE_OFF},  // si drive test -- alarm
{2, GA_STATUS_OFF, 	SILENCED, 	  GA_EVAC,   		RATE_ON},  // si drive test -- ga silence
{3, GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 		RATE_OFF},  // si drive test -- remove ga silence
{4, GA_STATUS_OFF, 	NOT_SILENCED, GA_NORMAL,		RATE_OFF},  // si drive test -- remove alarm
{5, GA_STATUS_OFF, 	NOT_SILENCED, GA_NORMAL, 		RATE_OFF},  // si drive test -- si ack-1
{6, GA_STATUS_OFF, 	NOT_SILENCED, GA_NORMAL, 		RATE_OFF},  // si drive test -- si ack-2

{7, GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 		RATE_OFF},  // directDrive test -- alarm
{8, GA_STATUS_OFF, 	SILENCED, 	  GA_EVAC,   		RATE_ON},  // directDrive test -- ga silence
{9, GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 		RATE_OFF}, // directDrive test -- remove ga silence

{10, GA_STATUS_OFF, NOT_SILENCED, GA_PRE_ALERT, 	RATE_OFF},  // preAlert Test -- alarm, verify in pre-alert
{11, GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 		RATE_OFF},
{12, GA_STATUS_ON, 	NOT_SILENCED, GA_ALERT, 		RATE_OFF},  // Alert Test -- alarm, verify in alert, alert ON
{13, GA_STATUS_OFF, NOT_SILENCED, GA_ALERT, 		RATE_OFF},  // Alert Test -- alarm, verify in alert, alert OFF

{14, GA_STATUS_ON, 	NOT_SILENCED, GA_NORMAL, 		RATE_OFF},  // si drive test -- si ack-2
{15, GA_STATUS_ON, 	NOT_SILENCED, GA_NORMAL, 		RATE_OFF},  // si drive test -- si ack-2
{16, GA_STATUS_ON, 	NOT_SILENCED, GA_NORMAL, 		RATE_OFF},
{17, GA_STATUS_ON, 	NOT_SILENCED, GA_NORMAL, 		RATE_OFF},
{18, GA_STATUS_ON, 	NOT_SILENCED, GA_PRE_ALERT,		RATE_OFF},  // preAlert Test -- alarm, verify in pre-alert
{19, GA_STATUS_OFF, SILENCED, 	  GA_ALERT, 		RATE_ON},
{20, GA_STATUS_ON, NOT_SILENCED,  GA_EVAC_INHIBIT_SILENCE, 		RATE_OFF},
{21, GA_STATUS_ON, NOT_SILENCED,  GA_EVAC_AUTO_SILENCE, 		RATE_OFF},
{22, GA_STATUS_OFF, SILENCED,  GA_EVAC_AUTO_SILENCE, 		RATE_ON}
/*
 tstNum, siStateFinal, 		gaOutputStatus,  gaSilence,   gaState, soObjectType, soObjectNum, soszTriggerValue, soEnabledState, gaSilenceLedRate;
{0, SI_STATE_IDLE, 				GA_STATUS_OFF, 	NOT_SILENCED, GA_NORMAL, SO_T_SO, 	SO_OBJ_1, 		(0<<0), 			IDLE,			RATE_OFF},  // test after init
{1, SI_STATE_alarmWaitForAck, 	GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 SO_T_SO, 	SO_OBJ_1, 		(1<<0), 			GA_ACTIVE,		RATE_OFF},  // si drive test -- alarm
{2, SI_STATE_alarmWaitForAck,	GA_STATUS_OFF, 	SILENCED, 	  GA_EVAC,   SO_T_SO, 	SO_OBJ_1, 		(0<<0),				IDLE,			RATE_ON},  // si drive test -- ga silence
{3, SI_STATE_alarmWaitForAck,	GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 SO_T_SO, 	SO_OBJ_1, 		(1<<0),				GA_ACTIVE,		RATE_OFF},  // si drive test -- remove ga silence
{4, SI_STATE_alarmWaitForAck,	GA_STATUS_OFF, 	NOT_SILENCED, GA_NORMAL, SO_T_SO, 	SO_OBJ_1, 		(0<<0),				IDLE,			RATE_OFF},  // si drive test -- remove alarm
{5, SI_STATE_alarmWaitForAck_afterResetOrFltClear,
								GA_STATUS_OFF, 	NOT_SILENCED, GA_NORMAL, SO_T_SO, 	SO_OBJ_1, 		(0<<0),				IDLE,			RATE_OFF},  // si drive test -- si ack-1
{6, SI_STATE_IDLE,				GA_STATUS_OFF, 	NOT_SILENCED, GA_NORMAL, SO_T_SO, 	SO_OBJ_1, 		(0<<0),				IDLE,			RATE_OFF},  // si drive test -- si ack-2

{7, SI_STATE_IDLE, 				GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 SO_T_SO, 	SO_OBJ_1, 		(1<<0), 			GA_ACTIVE,		RATE_OFF},  // directDrive test -- alarm
{8, SI_STATE_IDLE,				GA_STATUS_OFF, 	SILENCED, 	  GA_EVAC,   SO_T_SO, 	SO_OBJ_1, 		(0<<0),				IDLE,			RATE_ON},  // directDrive test -- ga silence
{9, SI_STATE_IDLE,				GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 SO_T_SO, 	SO_OBJ_1, 		(1<<0),				GA_ACTIVE,		RATE_OFF}, // directDrive test -- remove ga silence

{10, SI_STATE_IDLE, 			GA_STATUS_OFF, 	NOT_SILENCED, GA_PRE_ALERT, SO_T_SO, 	SO_OBJ_1, 	(0<<0), 			IDLE,			RATE_OFF},  // preAlert Test -- alarm, verify in pre-alert
{11, SI_STATE_IDLE, 			GA_STATUS_ON, 	NOT_SILENCED, GA_EVAC, 	 	SO_T_SO, 	SO_OBJ_1, 	(1<<0), 			GA_ACTIVE,		RATE_OFF},
{12, SI_STATE_IDLE, 			GA_STATUS_ON, 	NOT_SILENCED, GA_ALERT, 	SO_T_SO, 	SO_OBJ_1, 	(1<<0), 			GA_ACTIVE,		RATE_OFF},  // Alert Test -- alarm, verify in alert, alert ON
{13, SI_STATE_IDLE, 			GA_STATUS_OFF, 	NOT_SILENCED, GA_ALERT, 	SO_T_SO, 	SO_OBJ_1, 	(0<<0), 			IDLE,			RATE_OFF},  // Alert Test -- alarm, verify in alert, alert OFF

{14, SI_STATE_IDLE,				GA_STATUS_ON, 	NOT_SILENCED, GA_NORMAL, SO_T_SO, 	SO_OBJ_1, 		(1<<0),				GA_ACTIVE,			RATE_OFF},  // si drive test -- si ack-2
{15, SI_STATE_alarmWaitForAck,	GA_STATUS_ON, 	NOT_SILENCED, GA_NORMAL, SO_T_SO, 	SO_OBJ_1, 		(1<<0),				GA_ACTIVE,			RATE_OFF},  // si drive test -- si ack-2
{16, SI_STATE_alarmWaitForAck_afterResetOrFltClear,
								GA_STATUS_ON, 	NOT_SILENCED, GA_NORMAL, SO_T_SO, 	SO_OBJ_1, 		(1<<0),				GA_ACTIVE,			RATE_OFF},
{17, SI_STATE_IDLE, 			GA_STATUS_ON, 	NOT_SILENCED, GA_NORMAL, SO_T_SO, 	SO_OBJ_1, 		(1<<0),				GA_ACTIVE,			RATE_OFF},
{18, SI_STATE_IDLE, 			GA_STATUS_ON, 	NOT_SILENCED, GA_PRE_ALERT, SO_T_SO, 	SO_OBJ_1, 	(1<<0), 			GA_ACTIVE,			RATE_OFF},  // preAlert Test -- alarm, verify in pre-alert
*/
};
void Test_GA_setupGA(BYTE silenceInAlert, BYTE preAlertTimer, BYTE alertTimer, BYTE alertOn, BYTE alertOff, BYTE evacMin, BYTE autoSilence);
void Test_GA_testResult(/*enum SI_X siMe,*/ WORD testNum);
void Test_GA_templateSetup(enum eGA_States initState, enum Test_GA_id stateAfterAlarm);
void Test_GA_alertOnly_setup(BYTE silenceInAlert);
void Test_SI_SH_loadSI1NonLatchNoTimerGA(enum SI_X siMe);
void Test_SI_loadConfig(void);
void Test_SI_setUpInputTypes(void);
void r26fSiInputTypes1to8(void);
void r26gSiInputTypes2to9(void);
void r26hSetUpFunctionTypes(void);
void Test_Serial_setDebugStatus(enum DebugStatus status);
void Relay_set(enum Relays relay, enum Relay_Setting setting);
enum Relay_Setting Relay_getRequest(enum Relays resourceIndex, enum LED_INDEX requestorIndex);
void Fault_testThread(void);

int Fault_SOfaultLogic(unsigned char state, enum SO_fault mask, enum LED_INDEX led);
void Fault_powerFault_init(void);
void Fault_powerFault_test(void);

void Test_FWS_loadCfgSimple(void);
void Test_christmasTree(void)
{
    loadInhibitedSettings(pConfigMemRAM);
//	init_system();
	I2CioDriver_init();
	unsigned int i;
    while (1)
    {
        sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_0, 0x55);
		sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_1, 0x55);
		sendCmdData(PCA_U10_MISC_LED, PCA_OUTPUT_PORT_0, 0x55&~(OSO_MASK));
		sendCmdData(PCA_U10_MISC_LED, PCA_OUTPUT_PORT_1, 0x55);
		I2C_SO_Off(OSO_4 | OSO_2, 0x55);
		I2C_SO_On(OSO_3 | OSO_1, 0xAA);
//		I2C_SO_Off(0x55, 0);
//		I2C_SO_On(0xAA, 0);
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_0, 0x55);
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_1, 0x55);
		sendCmdData(PCA_U9,  PCA_OUTPUT_PORT_1, 0x55);
//		GPIO_setOutputLowOnPin(RELAY_1to3_PORT, RELAY_1_PIN | RELAY_2_PIN | RELAY_3_PIN);
//		GPIO_setOutputLowOnPin(RELAY_4_PORT, RELAY_4_PIN);

        for (i=0; i<50; i++)
        {
			__delay_cycles(10000);
        }

		sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_0, 0xAA);
		sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_1, 0xAA);
		sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, 0xAA&~(OSO_MASK));
		sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_1, 0xAA);
        I2C_SO_On(OSO_4 | OSO_2, 0xAA);
        I2C_SO_Off(OSO_3 | OSO_1, 0x55);
//		I2C_SO_On(0x55, 0);
//		I2C_SO_Off(0xAA, 0);
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_0, 0xAA);
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_1, 0xAA);
		sendCmdData(PCA_U9,  PCA_OUTPUT_PORT_1, 0xAA);

        for (i=0; i<50; i++)
        {
			__delay_cycles(10000);
        }
    }
}
unsigned char rcvdDataTst;
void I2CioDriver_test (void)
{
    //Stop WDT
//    WDT_A_hold(WDT_A_BASE);

//	Button_test();
//	Buzzer_test();
//	Relay_test();

	I2CioDriver_init();

    //Delay between each transaction
    __delay_cycles(50);

    //Load TX byte counter
//    transmitCounter = 0;
    unsigned int i;


    sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, ~STANDBY);
    sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, ~PRIMARY);
    sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, ~OSO_4);
    sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, ~OSO_3);
    sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, ~OSO_2);
    sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, ~OSO_1);
    sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, (unsigned char)~ALARMS);
//    sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, ~ALARM_2);

    for (i=0; i<8; i++)
	{
    	sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_0, ~(1<<i));
    	sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_1, ~(1<<i));
	}
    for (i=0; i<8; i++)
	{
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_0, ~(1<<i));
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_1, ~(1<<i));
	}
    for (i=0; i<8; i++)
	{
		sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, ~(1<<i));
		sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_1, ~(1<<i));
	}

    sendCmdData(PCA_U9, PCA_CONFIG_PORT_1, 0); // all outputs
	sendCmdData(PCA_U9, PCA_CONFIG_PORT_0, 0xFF); // all inputs
	for (i=0; i<8; i++)
	{
		sendCmdData(PCA_U9,  PCA_OUTPUT_PORT_1, ~(1<<i));
	}
    readCmdData(PCA_U9,  PCA_INPUT_PORT_0, &rcvdDataTst);

//    I2CioDriver_initTx();

    for (i=0; i<8; i++)
	{
    	sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_0, ~(i+1));
    	sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_1, ~(i+1));
	}
    for (i=0; i<8; i++)
	{
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_0, ~(i+1));
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_1, ~(i+1));
	}
    for (i=0; i<8; i++)
	{
		sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, ~(i+1));
		sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_1, ~(i+1));
	}
    I2CioDriver_test_thread();
}
void I2CioDriver_test_thread(void)
{
	unsigned int i;
    while (1)
    {
        sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_0, 0x55);
		sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_1, 0x55);
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_0, 0x55);
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_1, 0x55);
		sendCmdData(PCA_U10_MISC_LED, PCA_OUTPUT_PORT_0, 0x55);
		sendCmdData(PCA_U10_MISC_LED, PCA_OUTPUT_PORT_1, 0x55);
//		GPIO_setOutputLowOnPin(RELAY_1to3_PORT, RELAY_1_PIN | RELAY_2_PIN | RELAY_3_PIN);
//		GPIO_setOutputLowOnPin(RELAY_4_PORT, RELAY_4_PIN);

        for (i=0; i<50; i++)
        {
			__delay_cycles(10000);
        }

		sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_0, 0xAA);
		sendCmdData(PCA_U7_SI,  PCA_OUTPUT_PORT_1, 0xAA);
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_0, 0xAA);
		sendCmdData(PCA_U8_SO,  PCA_OUTPUT_PORT_1, 0xAA);
		sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_0, 0xAA);
		sendCmdData(PCA_U10_MISC_LED,  PCA_OUTPUT_PORT_1, 0xAA);
//		GPIO_setOutputHighOnPin(RELAY_1to3_PORT, RELAY_1_PIN | RELAY_2_PIN | RELAY_3_PIN);
//		GPIO_setOutputHighOnPin(RELAY_4_PORT, RELAY_4_PIN);


        for (i=0; i<50; i++)
        {
			__delay_cycles(10000);
        }

/*        for (i=0; i<6; i++)
        {
        	USCI_I2C_masterMultiByteSendStart(USCI_B1_BASE, transmitData[transmitCounter++]);
        	while (USCI_I2C_isBusBusy(USCI_B1_BASE)) ;
        }
        USCI_I2C_setSlaveAddress(USCI_B1_BASE,
                0x76
                );
        transmitCounter = 0;
        for (i=0; i<6; i++)
		{
			USCI_I2C_masterMultiByteSendStart(USCI_B1_BASE, transmitData[transmitCounter++]);
			while (USCI_I2C_isBusBusy(USCI_B1_BASE)) ;
		}*/
/*        for (i=0; i<3; i++)
        {
			//Initiate start and send first character
			USCI_I2C_masterMultiByteSendStart(USCI_B1_BASE, transmitData[transmitCounter++]);

			//Delay between each transaction
			__delay_cycles(10);

			USCI_I2C_masterMultiByteSendNext(USCI_B1_BASE, transmitData[transmitCounter++]);

			USCI_I2C_masterMultiByteSendStop(USCI_B1_BASE);

			//Delay between each transaction
			__delay_cycles(10);
        }
*/
        //Enter LPM0 with interrupts enabled
//        __bis_SR_register(LPM0_bits + GIE);
//        __no_operation();

        //Delay until transmission completes
//        while (USCI_I2C_isBusBusy(USCI_B1_BASE)) ;
    }
}
int Test_Serial_init(void)//(unsigned char * pBuffBegin, unsigned int buffSize)
{
#if ENABLE_DEBUG_SERIAL
#if ENABLE_DEBUG_SERIAL_UART
    //P5.6,7 = USCI_A0 TXD/RXD
    GPIO_setAsPeripheralModuleFunctionInputPin(
        GPIO_PORT_P5,
        GPIO_PIN6 + GPIO_PIN7
        );

    //Initialize USCI UART module
    if ( STATUS_FAIL == USCI_UART_init(USCI_A1_BASE,
             USCI_UART_CLOCKSOURCE_SMCLK,
             UCS_getSMCLK(UCS_BASE),
             BAUD_RATE,
             USCI_UART_NO_PARITY,
             USCI_UART_LSB_FIRST,
             USCI_UART_ONE_STOP_BIT,
             USCI_UART_MODE,
             USCI_UART_OVERSAMPLING_BAUDRATE_GENERATION
             )){
        return -3;
    }

    //Enable UART module for operation
    USCI_UART_enable(USCI_A1_BASE);

    //Enable Receive Interrupt
    USCI_UART_enableInterrupt(USCI_A1_BASE, USCI_UART_RECEIVE_INTERRUPT);
#endif
#endif
    Test_Serial_setDebugStatus(DEBUG_ENABLED);
    __no_operation(); // for breakpoint
    return 0;

//    configMem_updateFLASH(&buff[8], 5029);


    //Enter LPM3, interrupts enabled
//    __bis_SR_register(LPM3_bits + GIE);
}

void Test_Serial_sendCmdAndByte(enum DebugCmd cmd, unsigned char byte)
{
#if ENABLE_DEBUG_SERIAL
	if (Test_Serial_getDebugStatus() == DEBUG_DISABLED)
		return;

	while (!USCI_UART_getInterruptStatus(baseAddress, USCI_UART_TRANSMIT_INTERRUPT_FLAG)) ;
		USCI_UART_transmitData(baseAddress,(unsigned char)cmd);

	while (!USCI_UART_getInterruptStatus(baseAddress, USCI_UART_TRANSMIT_INTERRUPT_FLAG)) ;
			USCI_UART_transmitData(baseAddress, byte);
#endif
	__no_operation(); // for breakpoint
}
void Test_Serial_sendMsg(enum DebugCmd cmd, unsigned char numBytes)
{
#if ENABLE_DEBUG_SERIAL
	if (Test_Serial_getDebugStatus() == DEBUG_DISABLED)
			return;
	while (!USCI_UART_getInterruptStatus(baseAddress, USCI_UART_TRANSMIT_INTERRUPT_FLAG)) ;
		USCI_UART_transmitData(baseAddress,(unsigned char)cmd);
	unsigned int i = 0;
	while(numBytes--)
	{
		while (!USCI_UART_getInterruptStatus(baseAddress, USCI_UART_TRANSMIT_INTERRUPT_FLAG)) ;
			USCI_UART_transmitData(baseAddress, test_msg[i]);
		i++;
	}
#endif
	__no_operation(); // for breakpoint
}
void Test_Serial_sendCmdAndData(enum DebugCmd cmd, unsigned char * data, unsigned int numBytes)
{
#if ENABLE_DEBUG_SERIAL
	if (Test_Serial_getDebugStatus() == DEBUG_DISABLED)
			return;
	while (!USCI_UART_getInterruptStatus(baseAddress, USCI_UART_TRANSMIT_INTERRUPT_FLAG)) ;
		USCI_UART_transmitData(baseAddress,(unsigned char)cmd);

	while(numBytes--)
	{
		while (!USCI_UART_getInterruptStatus(baseAddress, USCI_UART_TRANSMIT_INTERRUPT_FLAG)) ;
			USCI_UART_transmitData(baseAddress,*data);
		data++;
	}
#endif
	__no_operation(); // for breakpoint
}
void Test_Serial_msgReset(void)
{
	memset(test_msg, 0x55, sizeof(test_msg));
}
int Test_Serial_msgAppend(unsigned char * _msg, unsigned int numBytes, unsigned char offset)
{
	unsigned int i = offset;
	test_msg_position = offset;
	if (offset > sizeof(test_msg))
	{
		return -1;
	}
	while (numBytes--)
	{
		test_msg[i] = *_msg;
		i++;
		_msg++;
		test_msg_position++;
	}
	return 0;
}
enum DebugStatus Test_Serial_getDebugStatus(void)
{
	return debugStatus;
}
void Test_Serial_setDebugStatus(enum DebugStatus status)
{
	debugStatus = status;
}
void Test_Serial_toggleDebugStatus(void)
{
	if (debugStatus == DEBUG_DISABLED)
	{
		debugStatus = DEBUG_ENABLED;
	}
	else if (debugStatus == DEBUG_ENABLED)
	{
		debugStatus = DEBUG_DISABLED;
	}
}
void I2C_SO_test_driver(const struct configMemRAM_t * pConfigMemRAM)
{
	volatile unsigned char buff;

	I2C_SO_AllOff();
	buff = I2C_SO_getSOstatus();
	I2C_SO_AllOn();
	buff = I2C_SO_getSOstatus();
	I2C_SO_AllOff();
	buff = I2C_SO_getSOstatus();
	I2C_SO_AllOn();
	I2C_SO_AllOff();
	I2C_SO_test();
	buff = I2C_SO_getSOstatus();
	I2C_SO_On(OSO_4, SO_4);
	buff = I2C_SO_getSOstatus();
	I2C_SO_Off(OSO_4, SO_4);
	buff = I2C_SO_getSOstatus();
	I2C_SO_On(OSO_4 | OSO_2, SO_4 | SO_2);
	buff = I2C_SO_getSOstatus();
	I2C_SO_Off(OSO_4 | OSO_2, SO_4 | SO_2);
	buff = I2C_SO_getSOstatus();
//    I2C_SO_AllOff();
//    buff = I2C_SO_getSOstatus();

	I2C_SO_On(OSO_3, SO_3);
	buff = I2C_SO_getSOstatus();
	I2C_SO_Off(OSO_3, SO_3);
	buff = I2C_SO_getSOstatus();

	I2C_SO_On(OSO_2, SO_2);
	buff = I2C_SO_getSOstatus();
	I2C_SO_Off(OSO_2, SO_2);
	buff = I2C_SO_getSOstatus();

	I2C_SO_On(OSO_1, SO_1);
	buff = I2C_SO_getSOstatus();
	I2C_SO_Off(OSO_1, SO_1);
	buff = I2C_SO_getSOstatus();
//    while (1)
//    {
//    	buff = I2C_SO_getSOstatus();
//    }
}

RTN_TYPE loadInhibitedSettings(const struct configMemRAM_t * _pConfigMemRAM)
{
//pConfigMemRAM->sysConfigAddress
//pConfigMemRAM->sysConfig
	struct configMemRAM_t * pConfigMemRAM = (struct configMemRAM_t *)_pConfigMemRAM;
	int i;
	for (i=0; i<TOTAL_SI; i++)
	{
		pConfigMemRAM->si[i].fxn /*& SI_EnabledMask */= SI_Fxn_INHIBIT_INPUT;
	}
	for (i=0; i<(TOTAL_SZ); i++)
	{
		pConfigMemRAM->sz[i].OutputControl = SO_configByte_OutputControl_disabled;
	}
	for (i=0; i<(TOTAL_SO); i++)
	{
		pConfigMemRAM->so[i].OutputControl = SO_configByte_OutputControl_disabled;
	}
	for (i=0; i<(MAX_REL); i++)
	{
		pConfigMemRAM->rl[i].OutputControl = SO_configByte_OutputControl_disabled;
	}
	pConfigMemRAM->hwTests.InhibitACTest = HWTestDisabled;
	pConfigMemRAM->hwTests.InhibitBatteryTest = HWTestDisabled;
	pConfigMemRAM->hwTests.InhibitGroundFaultTest = HWTestDisabled;
	pConfigMemRAM->hwTests.InhibitUPSTest = HWTestDisabled;

	//pConfigMemRAM->ga.

	pConfigMemRAM->xabort.AbortTimer = 0;

//	for (i=0; i<(TOTAL_FWS_SECTORS); i++) {
//		pConfigMemRAM->fws[i].
//	}

//pConfigMemRAM->revno.Start+1, size, offset);

/*	for (i=0; i<(TOTAL_FWS_SECTORS); i++) {
		pConfigMemRAM->fwsEx02[i]
	}
	for (i=0; i<(26); i++) {
		pConfigMemRAM->dspMessage[i]
		offset += size;//sizeof(struct SI) - 4;
	}*/
	return RTN_SUCCESS;
}
void test_SOfault(const struct configMemRAM_t * pConfigMemRAM)
{
//	I2C_SO_On(OSO_4, SO_4);
//	volatile unsigned char buff;
//	buff = I2C_SO_getSOstatus();
//	I2C_SO_Off(OSO_4, SO_4);

//	void I2C_SO_On(unsigned char maskOSO, unsigned char maskSO);
//  void I2C_SO_Off(unsigned char maskOSO, unsigned char maskSO);
	unsigned char state;
	I2C_SO_Off(OSO_1, SO_1); state = 0;
	LED_setRate(LED_SO_1_Alm, RATE_OFF);
	Fault_SOfaultLogic(state, SO_Flt_1, LED_SO_1_Flt);
/*		if (-1 == Fault_SOfaultLogic(state,SO_Flt_1))
		{
			LED_setRate(LED_SO_1_Flt, RATE_ON);
		}
		else
		{
			LED_setRate(LED_SO_1_Flt, RATE_OFF);
		}*/
		LED_thread();
	I2C_SO_On(OSO_1, SO_1); state = 1;
	LED_setRate(LED_SO_1_Alm, RATE_ON);
	Fault_SOfaultLogic(state, SO_Flt_1, LED_SO_1_Flt);
		/*if (-1 == Fault_SOfaultLogic(state,SO_Flt_1))
		{
			LED_setRate(LED_SO_1_Flt, RATE_ON);
		}
		else
		{
			LED_setRate(LED_SO_1_Flt, RATE_OFF);
		}*/
		LED_thread();
	I2C_SO_Off(OSO_1, SO_1); state = 0;
	LED_setRate(LED_SO_1_Alm, RATE_OFF);
	Fault_SOfaultLogic(state, SO_Flt_1, LED_SO_1_Flt);
		/*if (-1 == Fault_SOfaultLogic(state,SO_Flt_1))
		{
			LED_setRate(LED_SO_1_Flt, RATE_ON);
		}
		else
		{
			LED_setRate(LED_SO_1_Flt, RATE_OFF);
		}*/
		LED_thread();
}
void test_miscFaults(const struct configMemRAM_t * _pConfigMemRAM)
{
	struct configMemRAM_t * pConfigMemRAM = (struct configMemRAM_t *)_pConfigMemRAM;

	unsigned char t1 = pConfigMemRAM->hwTests.InhibitACTest;
	unsigned char t2 = pConfigMemRAM->hwTests.InhibitBatteryTest;
	unsigned char t3 = pConfigMemRAM->hwTests.InhibitGroundFaultTest;

	pConfigMemRAM->hwTests.InhibitACTest = HWTestEnabled;
	pConfigMemRAM->hwTests.InhibitBatteryTest = HWTestEnabled;
	pConfigMemRAM->hwTests.InhibitGroundFaultTest = HWTestEnabled;

	Fault_powerFault_init();

	// normal
	// 	ground -- system ground and chassis/earth ground are NOT connected
	// 	ac/dc -- leave inputs floating
	Fault_powerFault_test();

	// do ground fault -- short system ground to chassis/earth ground
	Fault_powerFault_test();

	// ac fault -- connect pin to ground
	Fault_powerFault_test();

	// dc fault --
	Fault_powerFault_test();

	pConfigMemRAM->hwTests.InhibitACTest = t1;
	pConfigMemRAM->hwTests.InhibitBatteryTest = t2;
	pConfigMemRAM->hwTests.InhibitGroundFaultTest = t3;

	Fault_powerFault_init();
	Fault_powerFault_test();
}
void test_fltAlmRelays(const struct configMemRAM_t * pConfigMemRAM)
{
	Relay_init();
	Relay_set(Relay_Alarm, Relay_On);
	Relay_set(Relay_Fault, Relay_On);
	Relay_set(Relay_1, Relay_On);
	Relay_set(Relay_2, Relay_On);
	Relay_set(Relay_3, Relay_On);
	Relay_set(Relay_4, Relay_On);
	Relay_set(Relay_Alarm, Relay_Off);
	Relay_set(Relay_Fault, Relay_Off);
	Relay_set(Relay_1, Relay_Off);
	Relay_set(Relay_2, Relay_Off);
	Relay_set(Relay_3, Relay_Off);
	Relay_set(Relay_4, Relay_Off);
	Relay_AllOff();
}
void test_harness(const struct configMemRAM_t * pConfigMemRAM)
{
	enum LED_GLOBAL_INDEX glob = globalLedToIndex(LED_ALARMS);// - LED_GLOBAL_BEGIN;
	LED_resourceArray_requestRate(glob, LED_SI_1_Alm, RATE_OFF);

    test_SOfault(pConfigMemRAM);
    test_miscFaults(pConfigMemRAM);
    test_fltAlmRelays(pConfigMemRAM);
}
void test_loadTestConfig_genericTester(const struct configMemRAM_t * _pConfigMemRAM)
{
	Test_SI_loadConfig();

		struct configMemRAM_t * pConfigMemRAM = (struct configMemRAM_t *)_pConfigMemRAM;

	//	pConfigMemRAM=(const struct configMemRAM_t *)&buff[0];
		pConfigMemRAM->revno.Revision = 0x83;

		pConfigMemRAM->hwTests.InhibitACTest = HWTestEnabled;
		pConfigMemRAM->hwTests.InhibitBatteryTest = HWTestEnabled;
		pConfigMemRAM->hwTests.InhibitGroundFaultTest = HWTestEnabled;

		LED_init();

		Test_GA_setupGA((BYTE)silenceInAlertDisabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_0, GA_TIMER_ALERT_ON_0, GA_TIMER_ALERT_OFF_0, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_0);

		int i;
		for (i=0; i<4; i++)
		{
			pConfigMemRAM->so[0].OutputControl = SO_configByte_OutputControl_disabled;
		}
		for (i=0; i<12; i++)
		{
			pConfigMemRAM->sz[0].OutputControl = SO_configByte_OutputControl_disabled;
		}
		for (i=0; i<4; i++)
		{
			pConfigMemRAM->rl[0].OutputControl = SO_configByte_OutputControl_disabled;
		}
		SOSZ_test_demoConfig_setup();

		if (SO_configByte_OutputControl_disabled == pConfigMemRAM->so[0].OutputControl)
		{
			__no_operation();
		}

		Test_Serial_init();
	//	SI_24VOutput_test2();
}
void Test_GA_loadConfig_r26bGaPreAlertOnly(void)
{
	Test_GA_templateSetup(GA_PRE_ALERT, stPreAlert_gaOff_notSil_ledOff);
}
void Test_GA_loadConfig_r26cGaAlertOnly(void)
{
	Test_GA_templateSetup(GA_ALERT, stAlert_gaOn_notSil_ledOff);
}
void Test_GA_loadConfig_r26cGaAlertOnly_silenceEnabled(void)
{
//	Test_GA_templateSetup(GA_ALERT, stAlert_gaOn_notSil_ledOff);
	Test_GA_alertOnly_setup(silenceInAlertEnabled);
}
void Test_GA_loadConfig_r26dGaEvacInhSilOnly(void)
{
	Test_GA_templateSetup(GA_EVAC_INHIBIT_SILENCE, stEvacInhSil_gaOn_notSil_ledOff);
}
void Test_GA_loadConfig_r26eGaEvacAutoSilOnly(void)
{
	Test_GA_templateSetup(GA_EVAC_AUTO_SILENCE, stEvacAutoSil_gaOn_notSil_ledOff);
}
void test_loadTestConfig_GAfxnSO1(const struct configMemRAM_t * _pConfigMemRAM, enum SI_X siMe)
{
	test_loadTestConfig_genericTester(_pConfigMemRAM);
	/* Setup GA silence during Alert = disabled, all timers set to zero*/
	Test_GA_setupGA((BYTE)silenceInAlertDisabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_0, GA_TIMER_ALERT_ON_0, GA_TIMER_ALERT_OFF_0, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_0);

	/* Set SI_1 for Normal GA, set all timers to 0*/
//	enum SI_X siMe = SI_1;
/*	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);

	Test_SI_SH_loadSI1NonLatchNoTimerGA(siMe);
	Test_SI_SH_loadSI1NonLatchNoTimerGA(SI_1);
	Test_SI_SH_loadSI1NonLatchNoTimerGA(SI_2);
	Test_SI_SH_loadSI1NonLatchNoTimerGA(SI_3);*/
	SOSZ_test_GAfxnSO(SO_OBJ_1, SO_T_SO);
}
void test_loadTestConfig(const struct configMemRAM_t * _pConfigMemRAM, enum SI_X siMe)
{
	test_loadTestConfig_genericTester(_pConfigMemRAM);

	// standard test config
	test_loadTestConfig_GAfxnSO1(_pConfigMemRAM, siMe);

	Test_FWS_loadCfgSimple();

	// Integration test configs (to avoid serial download)
//	Test_GA_loadConfig_r26bGaPreAlertOnly();
//	Test_GA_loadConfig_r26cGaAlertOnly();
//	Test_GA_loadConfig_r26cGaAlertOnly_silenceEnabled();
//	Test_GA_loadConfig_r26dGaEvacInhSilOnly();
//	Test_GA_loadConfig_r26eGaEvacAutoSilOnly();
//	r26fSiInputTypes1to8(); // r26fSiInputTypes1to8
//	r26gSiInputTypes2to9();
//	r26hSetUpFunctionTypes();

}
static unsigned char mask = 0;
void testPinPort8_init(unsigned char _mask)
{
	mask = 0;
	GPIO_setAsOutputPin(TEST_PIN_PORT, _mask);
	testPinPort8_off(_mask);
}
void testPinPort8_on(unsigned char _mask)
{
	mask |= _mask;
	GPIO_setOutputHighOnPin(TEST_PIN_PORT, mask);
}
void testPinPort8_off(unsigned char _mask)
{
	mask &= ~_mask;
	GPIO_setOutputLowOnPin(TEST_PIN_PORT, mask);
}
void test_testPin_init(void)
{
	GPIO_setAsOutputPin(TEST_PIN_PORT, TEST_PIN);
	test_testPin_Off();
}
void test_testPin_On(void)
{
	GPIO_setOutputHighOnPin(TEST_PIN_PORT, TEST_PIN);
}
void test_testPin_Off(void)
{
	GPIO_setOutputLowOnPin(TEST_PIN_PORT, TEST_PIN);
}
void test_testPin_toggle(void)
{
	GPIO_toggleOutputOnPin(TEST_PIN_PORT, TEST_PIN);
}
void test_testPin2_init(void)
{
	GPIO_setAsOutputPin(TEST_PIN_PORT2, TEST_PIN2);
	test_testPin2_Off();
}
void test_testPin2_On(void)
{
	GPIO_setOutputHighOnPin(TEST_PIN_PORT2, TEST_PIN2);
}
void test_testPin2_Off(void)
{
	GPIO_setOutputLowOnPin(TEST_PIN_PORT2, TEST_PIN2);
}
void test_testPin3_init(void)
{
	GPIO_setAsOutputPin(TEST_PIN_PORT3, TEST_PIN3);
	test_testPin3_Off();
}
void test_testPin3_On(void)
{
	GPIO_setOutputHighOnPin(TEST_PIN_PORT3, TEST_PIN3);
}
void test_testPin3_Off(void)
{
	GPIO_setOutputLowOnPin(TEST_PIN_PORT3, TEST_PIN3);
}
void test_testPin4_init(void)
{
	GPIO_setAsOutputPin(TEST_PIN_PORT4, TEST_PIN4);
	test_testPin4_Off();
}
void test_testPin4_On(void)
{
	GPIO_setOutputHighOnPin(TEST_PIN_PORT4, TEST_PIN4);
}
void test_testPin4_Off(void)
{
	GPIO_setOutputLowOnPin(TEST_PIN_PORT4, TEST_PIN4);
}
void Test_SI_setShortingTimes(unsigned char index0to11, unsigned char entry, unsigned char exit, enum SI_fwsEnable fwsEnable)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo((enum SI_X)index0to11);
	pSI_threadInfo->pSI->AlarmEntryTimer = entry;
	pSI_threadInfo->pSI->AlarmExitTimer = exit;
	pSI_threadInfo->pSI->FWSEntryTimerEnable = fwsEnable;
}
void Test_SI_setNonShortingTimes(unsigned char index0to11, unsigned char clear, unsigned char confirm, unsigned char smoke, unsigned char resetOn, unsigned char resetOff)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo((enum SI_X)index0to11);
	pSI_threadInfo->pSI->ClearTimer = clear;
	pSI_threadInfo->pSI->ConfirmationTimer = confirm;
	pSI_threadInfo->pSI->SmokeCheckTimer = smoke;
	pSI_threadInfo->pSI->ResetOnTimer = resetOn;
	pSI_threadInfo->pSI->ResetOffTimer = resetOff;
}
void Test_SI_setConfig(unsigned char index0to11, enum SI_functions config, enum SI_type inputType, enum SI_latch latch)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo((enum SI_X)index0to11);
	pSI_threadInfo->pSI->fxn = config;
	pSI_threadInfo->pSI->SWLatch = latch;
	pSI_threadInfo->pSI->InputType = inputType;
}
void Test_SI_NS_loadSI8nonShortWithSmokeAndClear(void)
{
	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_ALARM_NORMAL_GA, SI_TYPE6, SI_latch_isLatched);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF_10, TIME_CONFIRM_OFF_30, TIME_SMOKE_OFF_10, TIME_ROFF_OFF_5, TIME_RON_OFF_5);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_5, TIME_AlmExit_5, SI_fwsEnable_isSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);

	siMe = SI_2;
	pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_ALARM_NORMAL_GA, 	SI_TYPE6, SI_latch_notLatched);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF, TIME_SMOKE_OFF, TIME_ROFF_OFF, TIME_RON_OFF);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_5, TIME_AlmExit_5, SI_fwsEnable_notSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);//LED_SUPER
}
void Test_SI_NS_loadSI8nonShort_confirmResetTimers(void)
{
	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_ALARM_NORMAL_GA, SI_TYPE6, SI_latch_isLatched);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF_30, TIME_SMOKE_OFF, TIME_ROFF_OFF_5, TIME_RON_OFF_5);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_5, TIME_AlmExit_5, SI_fwsEnable_isSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);

	siMe = SI_2;
	pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_ALARM_NORMAL_GA, 	SI_TYPE6, SI_latch_notLatched);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF, TIME_SMOKE_OFF, TIME_ROFF_OFF, TIME_RON_OFF);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_5, TIME_AlmExit_5, SI_fwsEnable_notSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);//LED_SUPER
}
void Test_SI_SH_loadSI8alarmEntry(void)
{
	enum SI_X siMe = SI_8;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_SUPERVISORY, SI_TYPE4, SI_latch_notLatched);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF, TIME_SMOKE_OFF, TIME_ROFF_OFF, TIME_RON_OFF);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_5, TIME_AlmExit_5, SI_fwsEnable_notSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_SUPER);
}
void Test_SI_SH_loadSI1NonLatchNoTimerGA(enum SI_X siMe)
{
//	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_ALARM_NORMAL_GA, SI_TYPE4, SI_latch_notLatched);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF, TIME_SMOKE_OFF, TIME_ROFF_OFF, TIME_RON_OFF);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_0, TIME_AlmExit_0, SI_fwsEnable_notSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);
}
void Test_SI_SH_loadInputFxnType(enum SI_X siMe, enum SI_functions fxn, enum SI_type type, enum SI_latch latch)
{
//	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, fxn, type, latch);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF, TIME_SMOKE_OFF, TIME_ROFF_OFF, TIME_RON_OFF);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_0, TIME_AlmExit_0, SI_fwsEnable_notSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);

	SI_threadInfo_reset(pSI_threadInfo);
}
void Test_SI_NS_SM_xSecTicks(unsigned char siMe, struct evtArr_s * evts, unsigned char eventOneSecondTick, unsigned char secTicks)
{
	unsigned char secTick = 0, secTickStart = 0, secTickStop = secTicks;
	if (eventOneSecondTick)
	{
		secTickStart++;
		secTickStop++;
	}
	for (secTick = secTickStart; secTick < secTickStop; secTick++)
	{
		SI_NS_SM(siMe, &btnEvents, secTick);
	}
	LED_resourceArray_processLED();
}
void Test_SI_SH_SM_xSecTicks(unsigned char siMe, struct evtArr_s * evts, unsigned char eventOneSecondTick, unsigned char secTicks)
{
	unsigned char secTick = 0, secTickStart = 0, secTickStop = secTicks;
	if (eventOneSecondTick)
	{
		secTickStart++;
		secTickStop++;
	}
	for (secTick = secTickStart; secTick < secTickStop; secTick++)
	{
		SI_almShortingType_SM(siMe, &btnEvents, secTick);
	}
	LED_resourceArray_processLED();
}

void Test_SI_clearButtonEvents(void)
{
	BTN_btnEvent_testSet(eBtnAck, evt_no);
	BTN_btnEvent_testSet(eBtnReset, evt_no);
}
void Test_failureTrap(void)
{
	__no_operation(); // set breakpint here
}
void Test_SI_verifyIfUnackedFromLed(enum LED_INDEX me)
{
	if (me==LED_ALARMS || (/*(me>=LED_SI_1_Alm)&&*/(me<=LED_SI_8_Alm)))
	{
		if (LED_getRate(me) != RATE_FAST)
		{
			Test_failureTrap(); // fail
		}

	}
	else
	{
		if (LED_getRate(me) != RATE_SLOW)
		{
			Test_failureTrap(); // fail
		}
	}
}
struct siStateInfo_t testSiStateInfo;
pSiStateInfo_t pSiStateInfo = (pSiStateInfo_t)&testSiStateInfo;// = Test_SI_NS_returnCurrentState(siMe);
void Test_SI_SH_verifyOutputs(enum SI_STATE targetState, enum SI_X siMe)
{
	memset((BYTE*)pSiStateInfo, 0, sizeof(testSiStateInfo));
	SI_test_NS_packDesiredState(pSiStateInfo, targetState);
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);

	enum LED_INDEX globalAlarmLed = pSI_threadInfo->globalAlarmLed;
	enum LED_INDEX alarmLed = pSI_threadInfo->alarmLed;

	if (LED_ALARMS == globalAlarmLed)
	{
		if (LED_getRate(globalAlarmLed) != pSiStateInfo->alarmLedsRate)
		{
			Test_failureTrap(); // fail
		}
		if (LED_getRate(alarmLed) != pSiStateInfo->locLedRateIfAlarm)
		{
				Test_failureTrap(); // fail
		}
		if (Relay_getRequest(Relay_Alarm, alarmLed) != pSiStateInfo->myRelaySetting)
		{
			Test_failureTrap(); // fail
		}
	}
	else
	{
		if (LED_getRate(pSI_threadInfo->globalAlarmLed) != pSiStateInfo->supervisoryRate)
		{
			Test_failureTrap(); // fail
		}
		if (LED_getRate(pSI_threadInfo->alarmLed) != pSiStateInfo->locLedRateIfSuper)
		{
			Test_failureTrap(); // fail
		}
		if (Relay_getRequest(Relay_Fault, pSI_threadInfo->alarmLed) != pSiStateInfo->myRelaySetting)
		{
			Test_failureTrap(); // fail
		}
	}
}
struct siStateInfo_t testSiStateInfo;
pSiStateInfo_t Test_SI_getStateInfo(void)
{
	return (pSiStateInfo_t)&testSiStateInfo;
}
void Test_SI_verifyOutputs(enum SI_STATE targetState, enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
//	struct siStateInfo_t testSiStateInfo;
//	memset((BYTE*)&testSiStateInfo, 0, sizeof(testSiStateInfo));
	pSiStateInfo_t pSiStateInfo = Test_SI_getStateInfo();//(pSiStateInfo_t)&testSiStateInfo;// = Test_SI_NS_returnCurrentState(siMe);
	SI_test_NS_packDesiredState(pSiStateInfo, targetState);

	enum LED_INDEX globalAlarmLed = pSI_threadInfo->globalAlarmLed;
	enum LED_INDEX alarmLed = pSI_threadInfo->alarmLed;

	if (LED_ALARMS == globalAlarmLed)
	{
		if (LED_getRate(globalAlarmLed) != pSiStateInfo->alarmLedsRate)
		{
			if (pSI_threadInfo->isAcked == 0)
			{
				Test_SI_verifyIfUnackedFromLed(globalAlarmLed);
			}
			else
			{
				Test_failureTrap(); // fail
			}
		}
		if (LED_getRate(alarmLed) != pSiStateInfo->locLedRateIfAlarm)
		{
			if (pSI_threadInfo->isAcked == 0)
			{
				Test_SI_verifyIfUnackedFromLed(alarmLed);
			}
			else
			{
				Test_failureTrap(); // fail
			}
		}
		if (Relay_getRequest(Relay_Alarm, alarmLed) != pSiStateInfo->myRelaySetting)
		{
			Test_failureTrap(); // fail
		}
	}
	else if ((LED_SUPER == globalAlarmLed))
	{
		if (LED_getRate(pSI_threadInfo->globalAlarmLed) != pSiStateInfo->supervisoryRate)
		{
			Test_failureTrap(); // fail
		}
		if (LED_getRate(pSI_threadInfo->alarmLed) != pSiStateInfo->locLedRateIfSuper)
		{
			Test_failureTrap(); // fail
		}
		if (Relay_getRequest(Relay_Fault, pSI_threadInfo->alarmLed) != pSiStateInfo->myRelaySetting)
		{
			Test_failureTrap(); // fail
		}
	}
	else // not alarm or supervisory function
	{
//		if (pConfigMemRAM->si[siMe].InputType > SI_TYPE5) // non-shorting type...wait..shouldn't this check be for latching type?
		if (pSI_threadInfo->pSI->SWLatch == SI_latch_isLatched)
		{
			if (LED_getRate(alarmLed) != pSiStateInfo->locLedRateIfAlarm)
			{
				if (pSI_threadInfo->isAcked == 0)
				{
					Test_SI_verifyIfUnackedFromLed(alarmLed);
				}
				else
				{
					Test_failureTrap(); // fail
				}
			}
		}
		else
		{
			if (Relay_getRequest(Relay_Alarm, alarmLed) != Relay_Off)
			{
				Test_failureTrap(); // fail
			}
			if (Relay_getRequest(Relay_Fault, alarmLed) != Relay_Off)
			{
				Test_failureTrap(); // fail
			}
			if (LED_getRate(LED_ALARMS) != RATE_OFF)
			{
				Test_failureTrap(); // fail
			}
			if (LED_getRate(LED_SUPER) != RATE_OFF)
			{
				Test_failureTrap(); // fail
			}
			if (LED_getRate(pSI_threadInfo->alarmLed) != pSiStateInfo->locLedRateIfAlarm)
			{
				Test_failureTrap(); // fail
			}
			if (pSI_threadInfo->pSI->fxn == SI_Fxn_STATUS_CHANGE)
			{
				if (LED_Buzzer_getRate() != pSiStateInfo->locLedRateIfAlarm)
				{
					Test_failureTrap(); // fail
				}
			}
			else if (pSI_threadInfo->pSI->fxn == SI_Fxn_SILENT_STATUS_CHANGE)
			{
				if (LED_Buzzer_getRate() != RATE_OFF)
				{
					Test_failureTrap(); // fail
				}
			}
		}

	}
//	REL_resourceArray_processRELAY();
}
int Test_verifyUint8(unsigned char me, unsigned char target)
{
	if (me != target)
	{
		Test_failureTrap(); // fail
		return -1;
	}
	return 0;
}
void Test_SI_verifyState(enum SI_STATE myState, enum SI_STATE targetState)
{
	if (myState != targetState)
	{
		Test_failureTrap(); // fail
	}
}
void Test_verifyCountDownState(enum SI_X siMe, enum SI_STATE countDownState, unsigned char timer, unsigned char timeout)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	unsigned char secTick = 0;
//		Test_SI_clearButtonEvents();
		for (secTick=0; secTick < timeout; secTick++)
		{
			Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, secTick, 1);
			if (pSI_threadInfo->alarmState == countDownState)
			{
				__no_operation();
			}
			else
			{
				if (secTick == timer+1)
				{
					__no_operation();
				}
				else
				{
					Test_failureTrap(); // fail
				}
				break; // done @ 6
			}
		}
}
void Test_SI_NS_stateIDLE_verifyNoResponseToButtonPresses(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	pSI_threadInfo->adcState = SI_ADC_NORMAL;//SI_ADC_ALARM;
	BTN_btnEvent_testSet(eBtnAck, evt_yes); // verify that this btn press is not captured
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_IDLE);
	Test_verifyUint8(pSI_threadInfo->isAcked, 0);
	Test_SI_verifyOutputs(SI_STATE_IDLE, siMe);

	BTN_btnEvent_testSet(eBtnAck, evt_no); // clear the ack event, this would happen automatically at end of SI_thread
}
void Test_SI_NS_stateIDLE_verifyTransitionToSmokeCheckWaitForAck_afterAlarm_endSmokeCheckWaitForAck(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_smokeCheck_waitForAck);
	Test_SI_verifyOutputs(SI_STATE_NS_smokeCheck_waitForAck, siMe);
}
void Test_SI_NS_stateIDLE_verifyTransitionToAlarmWaitForAck_afterAlarm_endWaitForAck1(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForAck);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForAck, siMe);
}
void Test_SI_NS_stateWaitForAck_verifyNoResponseToResetButtonPress_endWaitForAck1(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	pSI_threadInfo->adcState = SI_ADC_NORMAL;
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForAck);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForAck, siMe);
	Test_verifyUint8(pSI_threadInfo->isAcked, 0);
	BTN_btnEvent_testSet(eBtnReset, evt_no); // clear the reset event, this would happen automatically at end of SI_thread
}
void Test_SI_NS_stateWaitForAck_verifyTransistionToWaitForReset_afterAckPressed_endWaitForReset(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	BTN_btnEvent_testSet(eBtnAck, evt_yes);
	Test_verifyUint8(pSI_threadInfo->isAcked, 0);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForReset);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForReset, siMe);
	Test_verifyUint8(pSI_threadInfo->isAcked, 1);
}
void Test_SI_NS_stateWaitForAckAfterAlmClear_verifyTransitionToWaitForAck1AfterAlarm_endWaitForAck1(enum SI_X siMe)
{ // not implmented correctly
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForAck);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForAck, siMe);
}
void Test_SI_NS_stateWaitForAckAfterAlmClear_verifyTransitionToIdleAfterAck_endIdle(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	BTN_btnEvent_testSet(eBtnAck, evt_yes);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_IDLE);
	Test_SI_verifyOutputs(SI_STATE_IDLE, siMe);
}
void Test_SI_NS_stateWaitForAckAfterAlmClear_verifyTransitionToWaitForResetAfterAckWithAlarm_endWaitForReset(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	BTN_btnEvent_testSet(eBtnAck, evt_yes);
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForReset);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForReset, siMe);
	Test_verifyUint8(pSI_threadInfo->isAcked, 1);
}
void Test_SI_NS_stateWaitForReset_verifyNoTransistionAfterAckPressed_endWaitForReset(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	BTN_btnEvent_testSet(eBtnAck, evt_yes);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForReset);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForReset, siMe);
	Test_verifyUint8(pSI_threadInfo->isAcked, 1);
	BTN_btnEvent_testSet(eBtnAck, evt_no); // clear the ack event, this would happen automatically at end of SI_thread
}
void Test_SI_NS_stateWaitForReset_verifyTransistionToResetOff_afterResetPressed_endResetOff(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_resetOff);
	Test_SI_verifyOutputs(SI_STATE_NS_resetOff, siMe);
	Test_verifyUint8(pSI_threadInfo->isAcked, 1);
	BTN_btnEvent_testSet(eBtnReset, evt_no); // clear the reset event, this would happen automatically at end of SI_thread
}
void Test_SI_NS_stateResetOff_verifyTransitionToStateWaitForResetAfterResetCycleWithAlarmPresent_endWaitForReset(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForReset);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForReset, siMe);
}
void Test_SI_NS_stateResetOff_verifyTransitionToStateWaitForAckAfterResetCycleWithFailurePresentIfNotAcked_endWaitForAck1(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForAck);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForAck, siMe);
}
void Test_SI_NS_stateResetOn_verifyTransitionToClearWithNoAlarmPresent_endClear(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_clearTimer);
	Test_SI_verifyOutputs(SI_STATE_NS_clearTimer, siMe);
}
void Test_SI_NS_stateResetOn_verifyTransitionToStateConfirmAfterResetCycleWithNoAlarmPresent_endConfirm(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_confirmTimer);
	Test_SI_verifyOutputs(SI_STATE_NS_confirmTimer, siMe);
}
void Test_SI_NS_stateClear_verifyTransitionToStateConfirmAfterResetCycleAndClearWithNoAlarmPresent_endConfirm(enum SI_X siMe)
{
	Test_SI_NS_stateResetOn_verifyTransitionToStateConfirmAfterResetCycleWithNoAlarmPresent_endConfirm(siMe);
}
void Test_SI_NS_stateConfirm_verifyTransitionToWaitForAckAfterAlmClearAfterStateConfirmWithNoAlarmPresent_endWaitForAck2(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForAck_afterResetAndAlmClear);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForAck_afterResetAndAlmClear, siMe);
}
void Test_SI_NS_latching_ackInWaitForAckAfterAlmClearWithNoAlarm_endTBD(siMe)
{

}
void Test_SI_NS_latching_initAlarmSmokeCheck_endSmokeCheck(enum SI_X siMe)
{
	Test_SI_NS_stateIDLE_verifyNoResponseToButtonPresses(siMe);
	Test_SI_NS_stateIDLE_verifyTransitionToSmokeCheckWaitForAck_afterAlarm_endSmokeCheckWaitForAck(siMe);
}
void Test_SI_NS_latching_initAlarm_endWaitForAck1(enum SI_X siMe)
{
	Test_SI_NS_stateIDLE_verifyNoResponseToButtonPresses(siMe);
	Test_SI_NS_stateIDLE_verifyTransitionToAlarmWaitForAck_afterAlarm_endWaitForAck1(siMe);
}
void Test_SI_NS_latching_waitForAck_ackAndResetButtonPresses_endInResetOffAlmPresent(enum SI_X siMe)
{
	Test_SI_NS_stateWaitForAck_verifyNoResponseToResetButtonPress_endWaitForAck1(siMe);
	Test_SI_NS_stateWaitForAck_verifyTransistionToWaitForReset_afterAckPressed_endWaitForReset(siMe);
	Test_SI_NS_stateWaitForReset_verifyNoTransistionAfterAckPressed_endWaitForReset(siMe);
	Test_SI_NS_stateWaitForReset_verifyTransistionToResetOff_afterResetPressed_endResetOff(siMe);
}
void Test_SI_NS_latching_afterSmokeCheckAlmPresentToResetOff_endResetOff(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_verifyCountDownState(siMe, SI_STATE_NS_smokeCheck_waitForAck, pSI_threadInfo->pSI->SmokeCheckTimer, pSI_threadInfo->pSI->SmokeCheckTimer+10);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_resetOff);
	Test_SI_verifyOutputs(SI_STATE_NS_resetOff, siMe);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_resetOff);
	Test_SI_verifyOutputs(SI_STATE_NS_resetOff, siMe);
}
void Test_SI_NS_latching_ackInSmokeCheckToSmokeAckedToResetOff_endResetOff(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_smokeCheck_waitForAck);
	Test_SI_verifyOutputs(SI_STATE_NS_smokeCheck_waitForAck, siMe);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 1, 1);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 1, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_smokeCheck_waitForAck);
	Test_SI_verifyOutputs(SI_STATE_NS_smokeCheck_waitForAck, siMe);
	Test_SI_clearButtonEvents();
	BTN_btnEvent_testSet(eBtnAck, evt_yes);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 1, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_smokeCheck_Acked);
	Test_SI_verifyOutputs(SI_STATE_NS_smokeCheck_Acked, siMe);
	Test_verifyCountDownState(siMe, SI_STATE_NS_smokeCheck_Acked, pSI_threadInfo->pSI->SmokeCheckTimer-3, pSI_threadInfo->pSI->SmokeCheckTimer+10);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_resetOff);
	Test_SI_verifyOutputs(SI_STATE_NS_resetOff, siMe);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_resetOff);
	Test_SI_verifyOutputs(SI_STATE_NS_resetOff, siMe);

}
void Test_SI_NS_latching_ackInResetCycleAlarmPresentAtEnd_endResetOn(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_clearButtonEvents();
	Test_verifyCountDownState(siMe, SI_STATE_NS_resetOff, pSI_threadInfo->pSI->ResetOffTimer, 10);
	BTN_btnEvent_testSet(eBtnAck, evt_yes);
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_verifyCountDownState(siMe, SI_STATE_NS_resetOn, pSI_threadInfo->pSI->ResetOnTimer, 10);
	Test_SI_clearButtonEvents();
}
void Test_SI_NS_latching_resetCycleAlarmPresentAtEnd_endResetOn(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_verifyCountDownState(siMe, SI_STATE_NS_resetOff, pSI_threadInfo->pSI->ResetOffTimer, 10);
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_verifyCountDownState(siMe, SI_STATE_NS_resetOn, pSI_threadInfo->pSI->ResetOnTimer, 10);
//	Test_SI_NS_stateResetOff_verifyResetOffCountdown(siMe, pSI_threadInfo->pSI->ResetOnTimer, 10);
//	Test_SI_NS_stateResetOff_verifyTransitionToStateWaitForResetAfterResetCycleWithAlarmPresent_endWaitForReset(siMe);
}
void Test_SI_NS_latching_resetCycleNoAlarmPresentAtEnd_endClearOrConfirm(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_verifyCountDownState(siMe, SI_STATE_NS_resetOff, pSI_threadInfo->pSI->ResetOffTimer, 10);
	pSI_threadInfo->adcState = SI_ADC_NORMAL;
	Test_verifyCountDownState(siMe, SI_STATE_NS_resetOn, pSI_threadInfo->pSI->ResetOnTimer, 10);
//	Test_SI_NS_stateResetOff_verifyResetOffCountdown(siMe, pSI_threadInfo->pSI->ResetOnTimer, 10);
	if (pSI_threadInfo->pSI->ClearTimer)
	{
		Test_SI_NS_stateResetOn_verifyTransitionToClearWithNoAlarmPresent_endClear(siMe);
	}
	else
	{
		Test_SI_NS_stateResetOn_verifyTransitionToStateConfirmAfterResetCycleWithNoAlarmPresent_endConfirm(siMe);
	}
}
void Test_SI_NS_latching_clearTimerWithNoAlarm_endConfirm(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	pSI_threadInfo->adcState = SI_ADC_NORMAL;
	unsigned char timer = pSI_threadInfo->pSI->ClearTimer;
	Test_verifyCountDownState(siMe, SI_STATE_NS_clearTimer, timer, timer+10);
	Test_SI_NS_stateClear_verifyTransitionToStateConfirmAfterResetCycleAndClearWithNoAlarmPresent_endConfirm(siMe);
}
void Test_SI_NS_latching_confirmTimerWithNoAlarm_endWaitForAck2(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	pSI_threadInfo->adcState = SI_ADC_NORMAL;
	unsigned char timer = pSI_threadInfo->pSI->ConfirmationTimer;
	Test_verifyCountDownState(siMe, SI_STATE_NS_confirmTimer, timer, timer+10);
	Test_SI_NS_stateConfirm_verifyTransitionToWaitForAckAfterAlmClearAfterStateConfirmWithNoAlarmPresent_endWaitForAck2(siMe);
}
void Test_SI_NS_latching_alarmDuringConfirm_endWaitForReset(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_confirmTimer);
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 1, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_NS_alarmWaitForReset);
}
void Test_SI_NS_latching_noAlarmAtEndOfResetOrClear_endClearOrConfirm(enum SI_X siMe)
{
//	Test_SI_NS_latching_initAlarm_endWaitForAck1(siMe);
//	Test_SI_NS_latching_waitForAck_ackAndResetButtonPresses_endInResetOffAlmPresent(siMe);
	Test_SI_NS_latching_resetCycleNoAlarmPresentAtEnd_endClearOrConfirm(siMe);
}
void Test_SI_NS_latching_noAlarmAtClear_endTBD(enum SI_X siMe)
{
//	Test_SI_NS_latching_confirmTimerWithAlarm(siMe);
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	if (pSI_threadInfo->pSI->ClearTimer)
	{
		Test_SI_NS_latching_clearTimerWithNoAlarm_endConfirm(siMe);
		pSI_threadInfo->adcState = SI_ADC_NORMAL;
		Test_SI_NS_latching_ackInWaitForAckAfterAlmClearWithNoAlarm_endTBD(siMe);
	}
}
void Test_SI_NS_latching_noAlarmAtConfirm_endWaitForAck2(enum SI_X siMe)
{
//	Test_SI_NS_latching_confirmTimerWithAlarm(siMe);
	Test_SI_NS_latching_confirmTimerWithNoAlarm_endWaitForAck2(siMe);
}
void Test_SI_NS_latching_noAlarmAtEndOfResetOrClearOrConfirm_endWaitForAck2(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_NS_latching_noAlarmAtEndOfResetOrClear_endClearOrConfirm(siMe);
	Test_SI_NS_latching_noAlarmAtClear_endTBD(siMe);
	Test_verifyUint8(pSI_threadInfo->isAcked, 1);//pSI_threadInfo->isAcked, 1);
	pSI_threadInfo->adcState = SI_ADC_NORMAL;//pSI_threadInfo->adcState = SI_ADC_NORMAL;
	Test_SI_NS_latching_ackInWaitForAckAfterAlmClearWithNoAlarm_endTBD(siMe);
	Test_SI_NS_latching_noAlarmAtConfirm_endWaitForAck2(siMe);
	Test_verifyUint8(pSI_threadInfo->isAcked, 1);//pSI_threadInfo->isAcked, 1);
}
void Test_SI_NS_latching_alarmDuringWaitForAck2AfterAlarmClearNoAlm_endWaitForAck1(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_NS_stateWaitForAckAfterAlmClear_verifyTransitionToWaitForAck1AfterAlarm_endWaitForAck1(siMe); // not implmented correctly, ends in wait for ack, not reset
}
void Test_SI_NS_latching_ackInWaitForAckAfterAlarmClearNoAlmToIdle_endIdle(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	pSI_threadInfo->adcState = SI_ADC_NORMAL;
	Test_SI_NS_stateWaitForAckAfterAlmClear_verifyTransitionToIdleAfterAck_endIdle(siMe);
//	Test_SI_NS_stateWaitForAckAfterAlmClear_verifyTransitionToWaitForResetAfterAckWithAlarm_endWaitForReset(siMe);
}
void Test_SI_NS_latching_reset_smokeCheckAlmPresentToResetOffNoAck_endResetOff(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	SI_threadInfo_reset(pSI_threadInfo);
	Test_SI_NS_latching_initAlarmSmokeCheck_endSmokeCheck(siMe);
	Test_SI_NS_latching_afterSmokeCheckAlmPresentToResetOff_endResetOff(siMe);
//	Test_SI_NS_latching_waitForAck_ackAndResetButtonPresses_endInResetOffAlmPresent(siMe);
}
void Test_SI_NS_latching_reset_smokeCheckToResetAlmPresentToWaitForAck_endWaitForAck1(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_NS_latching_reset_smokeCheckAlmPresentToResetOffNoAck_endResetOff(siMe);
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_NS_latching_resetCycleAlarmPresentAtEnd_endResetOn(siMe);
	Test_SI_NS_stateResetOff_verifyTransitionToStateWaitForAckAfterResetCycleWithFailurePresentIfNotAcked_endWaitForAck1(siMe);
}
void Test_SI_NS_latching_reset_smokeCheckToAckInResetAlmPresentToWaitForReset_endWaitForReset(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_NS_latching_reset_smokeCheckAlmPresentToResetOffNoAck_endResetOff(siMe);
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_NS_latching_ackInResetCycleAlarmPresentAtEnd_endResetOn(siMe);
	Test_SI_NS_stateResetOff_verifyTransitionToStateWaitForResetAfterResetCycleWithAlarmPresent_endWaitForReset(siMe);
}
void Test_SI_NS_latching_reset_ackInSmokeCheckToSmokeAckedAlmPresentToResetOff_endResetOff(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	SI_threadInfo_reset(pSI_threadInfo);
	Test_SI_NS_latching_initAlarmSmokeCheck_endSmokeCheck(siMe);
	Test_SI_NS_latching_ackInSmokeCheckToSmokeAckedToResetOff_endResetOff(siMe);
}
void Test_SI_NS_latching_reset_smokeCheckNoAlarmAtEndOfResetOrClearOrConfirmThenAck_endIdle(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_NS_latching_reset_ackInSmokeCheckToSmokeAckedAlmPresentToResetOff_endResetOff(siMe);
	pSI_threadInfo->adcState = SI_ADC_NORMAL;
	Test_SI_NS_latching_noAlarmAtEndOfResetOrClearOrConfirm_endWaitForAck2(siMe);
	Test_SI_NS_latching_ackInWaitForAckAfterAlarmClearNoAlmToIdle_endIdle(siMe);
}
void Test_SI_NS_latching_reset_alarmStillPresentAfterReset_endInWaitForReset(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	SI_threadInfo_reset(pSI_threadInfo);
	Test_SI_NS_latching_initAlarm_endWaitForAck1(siMe);
	Test_SI_NS_latching_waitForAck_ackAndResetButtonPresses_endInResetOffAlmPresent(siMe);
	Test_SI_NS_latching_resetCycleAlarmPresentAtEnd_endResetOn(siMe);
	Test_SI_NS_stateResetOff_verifyTransitionToStateWaitForResetAfterResetCycleWithAlarmPresent_endWaitForReset(siMe);
}
void Test_SI_NS_latching_reset_noAlarmAtEndOfResetOrClearOrConfirmThenAck_endIdle(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	SI_threadInfo_reset(pSI_threadInfo);
	Test_SI_NS_latching_initAlarm_endWaitForAck1(siMe);
	Test_SI_NS_latching_waitForAck_ackAndResetButtonPresses_endInResetOffAlmPresent(siMe);
	Test_SI_NS_latching_noAlarmAtEndOfResetOrClearOrConfirm_endWaitForAck2(siMe);
	Test_SI_NS_latching_ackInWaitForAckAfterAlarmClearNoAlmToIdle_endIdle(siMe);
}
void Test_SI_NS_latching_alarmDuringStateClear_endTBD(enum SI_X siMe)
{
	__no_operation();
}
void Test_SI_NS_latching_reset_alarmDuringStateConfirm_endWaitForReset(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	SI_threadInfo_reset(pSI_threadInfo);
	Test_SI_NS_latching_initAlarm_endWaitForAck1(siMe);
	Test_SI_NS_latching_waitForAck_ackAndResetButtonPresses_endInResetOffAlmPresent(siMe);

//	Test_SI_NS_latching_noAlarmAtEndOfResetOrClearOrConfirm_endWaitForAck2(siMe);
	Test_SI_NS_latching_noAlarmAtEndOfResetOrClear_endClearOrConfirm(siMe);
	Test_SI_NS_latching_alarmDuringConfirm_endWaitForReset(siMe);
}
void Test_SI_NS_latching_reset_alarmDuringWaitForAck2AfterAlmClear_endWaitForAck1(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	SI_threadInfo_reset(pSI_threadInfo);
	Test_SI_NS_latching_initAlarm_endWaitForAck1(siMe);
	Test_SI_NS_latching_waitForAck_ackAndResetButtonPresses_endInResetOffAlmPresent(siMe);
	Test_SI_NS_latching_noAlarmAtEndOfResetOrClearOrConfirm_endWaitForAck2(siMe);
	Test_SI_NS_latching_alarmDuringWaitForAck2AfterAlarmClearNoAlm_endWaitForAck1(siMe); // not implmented correctly, ends in wait for ack, not reset
}

void Test_SI_NS_latching_overrideAdcState_severalNStests(void)
{
//	unsigned char secTick = 0;
	enum SI_X siMe = SI_1;

Test_SI_NS_loadSI8nonShort_confirmResetTimers(); // france config -- non-shorting type 6, latching, resetOn=resetOff=5, confirm=30, clear=0, smoke=0

	Test_SI_NS_latching_reset_alarmStillPresentAfterReset_endInWaitForReset(siMe);

	Test_SI_NS_latching_reset_noAlarmAtEndOfResetOrClearOrConfirmThenAck_endIdle(siMe);

	Test_SI_NS_latching_reset_alarmDuringStateConfirm_endWaitForReset(siMe);
//	Test_SI_NS_latching_alarmDuringStateClear_endTBD(siMe);
	Test_SI_NS_latching_reset_alarmDuringWaitForAck2AfterAlmClear_endWaitForAck1(siMe);

Test_SI_NS_loadSI8nonShortWithSmokeAndClear();

//	Test_SI_NS_latching_reset_smokeCheckAlmPresentToResetOffNoAck_endResetOff(siMe);
	Test_SI_NS_latching_reset_smokeCheckToResetAlmPresentToWaitForAck_endWaitForAck1(siMe);
	Test_SI_NS_latching_reset_smokeCheckToAckInResetAlmPresentToWaitForReset_endWaitForReset(siMe);

	Test_SI_NS_latching_reset_ackInSmokeCheckToSmokeAckedAlmPresentToResetOff_endResetOff(siMe);

	Test_SI_NS_latching_reset_smokeCheckNoAlarmAtEndOfResetOrClearOrConfirmThenAck_endIdle(siMe);

	__no_operation();
}
WORD val;
BYTE count = 0;
void Test_SOSZ_someTest(void)
{
	// verify that SI_mask is set
	val = SOSZ_getSOSZ_SILoAlmTrigger();
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));

	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), TURN_ON_DELAY);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), IDLE);
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), IDLE);

	// call the SO thread, verify that the output and sw zone are driven
	SOSZ_thread(MODE_NORMAL);

	val = SOSZ_getSOSZ_SOtrigger();
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), STEADY_ON);
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_2), IDLE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_2), TURN_ON_DELAY);

	val = 0;
	count = 0;
	do {
		SOSZ_thread(MODE_NORMAL);
//		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);
		val = SOSZ_getSOSZ_SZLowTrigger();
		count++;
	} while(val==0);
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
	Test_verifyUint8(count, 2);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), STEADY_ON);

	val = SOSZ_getSOSZ_SOtrigger();
	Test_verifyUint8(val&(1<<SI_2), (1<<SI_2));
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_2), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_2), STEADY_ON);

	SOSZ_thread(MODE_NORMAL);

	val = SOSZ_getSOSZ_SOtrigger();
	Test_verifyUint8(val&(1<<SI_2), (1<<SI_2));
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_2), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_2), STEADY_ON);

	LED_test_marshalLEDperI2CportSOREL();
	val = SO_out_getLastOSOon();
	Test_verifyUint8(val&OSO__2, OSO__2);
	val = SO_out_getLastLEDon();
	Test_verifyUint8(val&SO_2, SO_2);
}
void Test_SI_SH_nonLatchNoTimer_idleToWaitForAck(BYTE useTestConfig)
{
/*
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_verifyUint8(pSI_threadInfo->isAcked, 1);
	Test_verifyCountDownState(siMe, SI_STATE_NS_smokeCheck_waitForAck, pSI_threadInfo->pSI->SmokeCheckTimer, pSI_threadInfo->pSI->SmokeCheckTimer+10);
*/
	// initialize data structures
//	unsigned char secTick = 0;
	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);

	if (useTestConfig)
	{
		Test_SI_SH_loadSI1NonLatchNoTimerGA(siMe);
		SOSZ_test_demoConfig_setup();
	}
	SI_init();
	LED_setRateRange(LED_Begin, LED_end, RATE_OFF);
	SI_threadInfo_reset(pSI_threadInfo);
	Test_SI_clearButtonEvents();
	SOSZ_init();

	// verify that we start in IDLE state
	// set Alarm, verify that we are in waitForAck state
	pSI_threadInfo->adcState = SI_ADC_NORMAL;
	Test_SI_SH_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_IDLE);
	Test_SI_SH_verifyOutputs(SI_STATE_IDLE, siMe);

	// set Alarm, verify that we are in waitForAck state
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_SH_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);

	// verify correct outptus for waitForAck state
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_alarmWaitForAck);
	Test_SI_SH_verifyOutputs(SI_STATE_alarmWaitForAck, siMe);

	// 1 press ack-1, alm present
	// 1 clear failure
	// 1 press ack-2, alm clear, back to idle

	// 2 clear failure
	// 2 press ack-1, alm clear
	// 2 press ack-2, alm clear

	// 3 press ack-1, alm present
	// 3 clear failure
	// 3 press ack-2, alm present, back to idle

//	Test_SOSZ_someTest();
}
void Test_SI_SH_centCfg_setAlmMonitorSOtimers(BYTE useTestConfig)
{
/*
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	Test_SI_NS_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_verifyUint8(pSI_threadInfo->isAcked, 1);
	Test_verifyCountDownState(siMe, SI_STATE_NS_smokeCheck_waitForAck, pSI_threadInfo->pSI->SmokeCheckTimer, pSI_threadInfo->pSI->SmokeCheckTimer+10);
*/
	// initialize data structures
//	unsigned char secTick = 0;

	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);

	if (useTestConfig)
	{
		Test_SI_SH_loadSI1NonLatchNoTimerGA(siMe);
		SOSZ_test_demoConfig_setup();
	}
	SI_init();
	LED_setRateRange(LED_Begin, LED_end, RATE_OFF);
	SI_threadInfo_reset(pSI_threadInfo);
	Test_SI_clearButtonEvents();
	SOSZ_init();

	// verify that we start in IDLE state
	// set Alarm, verify that we are in waitForAck state
	pSI_threadInfo->adcState = SI_ADC_NORMAL;
	Test_SI_SH_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_IDLE);
	Test_SI_SH_verifyOutputs(SI_STATE_IDLE, siMe);

	// set Alarm, verify that we are in waitForAck state
	pSI_threadInfo->adcState = SI_ADC_ALARM;
	Test_SI_SH_SM_xSecTicks((unsigned char)siMe, &btnEvents, 0, 1);

	// verify correct outptus for waitForAck state
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_alarmWaitForAck);
	Test_SI_SH_verifyOutputs(SI_STATE_alarmWaitForAck, siMe);

	// verify that SI_mask is set
	val = SOSZ_getSOSZ_SILoAlmTrigger();
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));

	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), IDLE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), TURN_ON_DELAY);
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), IDLE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);

	// call the SO thread, verify that the output and sw zone are driven
//	SOSZ_thread(MODE_NORMAL);

//	val = SOSZ_getSOSZ_SOtrigger();
//	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
//	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), ACTIVE);
//	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), STEADY_ON);
//	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), ACTIVE);
//	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);
//	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_2), IDLE);
//		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_2), TURN_ON_DELAY);
	SOSZ_thread(MODE_NORMAL);
	val = 0;
	count = 0;
	do {
		Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), IDLE);
		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), TURN_ON_DELAY);
		Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), ACTIVE);
		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);

		SOSZ_thread(MODE_NORMAL);
//		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);
		val = SOSZ_getSOSZ_SZTrigger();
		count++;
		if (count > 100) break;
	} while(val==0);
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
	Test_verifyUint8(count, 20);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), STEADY_ON);

	val = SOSZ_getSOSZ_SOtrigger();
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), STEADY_ON);

	SOSZ_thread(MODE_NORMAL);

	val = SOSZ_getSOSZ_SOtrigger();
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), STEADY_ON);

	LED_test_marshalLEDperI2CportSOREL();
	val = SO_out_getLastOSOon();
	Test_verifyUint8(val&OSO__1, OSO__1);
	val = SO_out_getLastLEDon();
	Test_verifyUint8(val&SO_1, SO_1);
}
void Test_SI_SH_centCfg_SZ2xTest(BYTE useTestConfig)
{
	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_SH_centCfg_setAlmMonitorSOtimers(useTestConfig);  // fails

	// clear SI1 Alarm
	SOSZ_clearSOSZ_SILoAlm((1<<SI_1));

	// verify that SI_mask is set
	val = SOSZ_getSOSZ_SILoAlmTrigger();
	Test_verifyUint8(val&(1<<SI_1), 0);

	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), STEADY_ON);

	val = SOSZ_getSOSZ_SOtrigger();
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), STEADY_ON);

	SOSZ_thread(MODE_NORMAL);

	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), IDLE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), STEADY_ON); // fails
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), STEADY_ON);

	do {
		Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), IDLE);
		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), STEADY_ON);
		Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), ACTIVE);
		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), STEADY_ON);

		SOSZ_thread(MODE_NORMAL);
//		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);
		val = SOSZ_getSOSZ_SOtrigger();
		count++;
		if (count > 100) break;
	} while(val==1);

	// clear SI1 Alarm
	SOSZ_notifySOSZ_SILoAlm((1<<SI_1));

	SOSZ_thread(MODE_NORMAL);

	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), IDLE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), TURN_OFF_DELAY);

	val = 0;
	count = 0;
	do {
		Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SZ, SO_OBJ_1), ACTIVE);
		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);
		Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), IDLE);
		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), TURN_OFF_DELAY);

		SOSZ_thread(MODE_NORMAL);
//		Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_ON_DELAY);
		val = SOSZ_getSOSZ_SZTrigger();
		count++;
	} while(val==0);
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
	Test_verifyUint8(count, 20);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), STEADY_ON);

	val = SOSZ_getSOSZ_SOtrigger();
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), STEADY_ON);

	SOSZ_thread(MODE_NORMAL);

	val = SOSZ_getSOSZ_SOtrigger();
	Test_verifyUint8(val&(1<<SI_1), (1<<SI_1));
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), ACTIVE);
	Test_verifyUint8( SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), STEADY_ON);
}
void Test_REL_resourceArray_requestRelay_requestTwice(void)
{
	Relay_init();
	REL_resourceArray_requestRelay(Relay_Fault, LED_SERVICE_MODE, Relay_On);
	REL_resourceArray_requestRelay(Relay_Fault, LED_SERVICE_MODE, Relay_On);
	REL_resourceArray_requestRelay(Relay_Fault, LED_SERVICE_MODE, Relay_On);
	REL_resourceArray_requestRelay(Relay_Fault, LED_SI_1_Alm, Relay_Off);
	REL_resourceArray_requestRelay(Relay_Fault, LED_SI_1_Alm, Relay_Off);
	REL_resourceArray_requestRelay(Relay_Fault, LED_SI_1_Alm, Relay_Off);
	REL_resourceArray_requestRelay(Relay_Fault, LED_SI_1_Alm, Relay_Off);
}
void Test_SI_ServiceMode(void)
{
	BTN_btnEvent_testSet(eBtnSvcMode, evt_yes); // clear the ack event, this would happen automatically at end of SI_thread
	SI_thread(1, SI_runMode_test, SI_runMode_test);
	SI_atomicTimer();
}
WORD Test_SI_threadParams(enum SI_X siMe, enum SI_ADC_STATE adcState, enum SI_STATE terminatingState, WORD maxIterations, enum SI_runMode adcRawMode, enum SI_runMode adcStatusMode, unsigned int adcCount)
{
	WORD secTick = 0;
//	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);

//	Test_SI_SH_loadSI8alarmEntry();

	pSI_threadInfo->adcState = adcState;
	pSI_threadInfo->adcCount = adcCount;

	SIadc_testIncrmentAdcTurn();
	SI_thread(1, adcRawMode, adcStatusMode);
	for (secTick=0; secTick < maxIterations; secTick++)
	{
		GA_thread();
		SIadc_testIncrmentAdcTurn();
//		SI_incrOneSecTick();
		SI_thread(1, adcRawMode, adcStatusMode);
		if (pSI_threadInfo->alarmState == terminatingState)
			break;
	}
	GA_thread();
	LED_buzzerLogic();
	return secTick;
}
void Test_SI_loadConfig(void)
{
	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_ALARM_NORMAL_GA, SI_TYPE6, SI_latch_notLatched);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF_30, TIME_SMOKE_OFF, TIME_ROFF_OFF_5, TIME_RON_OFF_5);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_5, TIME_AlmExit_5, SI_fwsEnable_isSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_SUPER);

//	enum SI_X siMe = SI_1;
	pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_ALARM_NORMAL_GA, SI_TYPE6, SI_latch_isLatched);
//	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF_10, TIME_CONFIRM_OFF_30, TIME_SMOKE_OFF_10, TIME_ROFF_OFF_5, TIME_RON_OFF_5);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF, TIME_SMOKE_OFF, TIME_ROFF_OFF, TIME_RON_OFF);
//	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_5, TIME_AlmExit_5, SI_fwsEnable_isSet);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_0, TIME_AlmExit_0, SI_fwsEnable_notSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);

	siMe = SI_2;
	pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_ALARM_NORMAL_GA, 	SI_TYPE6, SI_latch_isLatched);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF, TIME_SMOKE_OFF, TIME_ROFF_OFF, TIME_RON_OFF);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_5, TIME_AlmExit_5, SI_fwsEnable_notSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);//LED_SUPER

	siMe = SI_2;
	pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_setConfig(siMe, SI_Fxn_SUPERVISORY, 	SI_TYPE4, SI_latch_isLatched);
	Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF, TIME_SMOKE_OFF, TIME_ROFF_OFF, TIME_RON_OFF);
	Test_SI_setShortingTimes(siMe, TIME_AlmEntry_0, TIME_AlmExit_0, SI_fwsEnable_notSet);
	SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);//LED_SUPER

	for (siMe = SI_3; siMe <= SI_8; siMe++)
	{
		pSI_threadInfo = SI_rtnThreadInfo(siMe);
		Test_SI_setConfig(siMe, SI_Fxn_ALARM_NORMAL_GA, 	SI_TYPE4, SI_latch_isLatched);
		Test_SI_setNonShortingTimes(siMe, TIME_CLEAR_OFF, TIME_CONFIRM_OFF, TIME_SMOKE_OFF, TIME_ROFF_OFF, TIME_RON_OFF);
		Test_SI_setShortingTimes(siMe, TIME_AlmEntry_0, TIME_AlmExit_0, SI_fwsEnable_notSet);
		SI_threadInfo_setGlobalLed(pSI_threadInfo, LED_ALARMS);//LED_SUPER
	}

/*	Test_SI_setConfig(SI_3, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);
	Test_SI_setConfig(SI_4, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);
	Test_SI_setConfig(SI_5, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);
	Test_SI_setConfig(SI_6, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);
	Test_SI_setConfig(SI_7, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);*/
//	Test_SI_setConfig(SI_8, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);
//	Test_SI_setConfig(SI_9, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);
//	Test_SI_setConfig(SI_10, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);
//	Test_SI_setConfig(SI_11, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);
//	Test_SI_setConfig(SI_12, SI_Fxn_INHIBIT_INPUT, 	SI_TYPE4, SI_latch_isLatched);
}
void Test_SO_2xIssueSZturnOn(void)
{
	unsigned int i = 0;
	LED_setMode(MODE_NORMAL);
	SOSZ_notifySOSZ_SILoAlm(1<<0);
	for (i=0; i<132; i++)
	{
		SOSZ_thread(MODE_NORMAL);
		LED_test_marshalLEDperI2CportSOREL();
		Fault_testThread();
	}
	SOSZ_clearSOSZ_SILoAlm(1<<0);
	SOSZ_thread(MODE_NORMAL);
	LED_test_marshalLEDperI2CportSOREL();
	Fault_testThread();

	SOSZ_notifySOSZ_SILoAlm(1<<0);
	for (i=0; i<132; i++)
	{
		SOSZ_thread(MODE_NORMAL);
		LED_test_marshalLEDperI2CportSOREL();
		Fault_testThread();
	}
}
void Test_SO_pulseOnOff_setup(void)
{
	/* Init */
	SOSZ_init();

	struct SO * pSO = SOSZ_testGetSoPtr(SO_OBJ_1, SO_T_SO);
	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0xFF); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE siHi, BYTE siLo)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, 1);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 0, 0, 2, 4, 4);//2, 2);

	Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), IDLE);
}
void Test_SO_pulseOnOff_cycle(int numCycles, enum Active_state s1, enum Active_state s2)
{
	int i;
	for (i=0; i<numCycles; i++)
	{
		SOSZ_thread(MODE_NORMAL);
		Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), s1);

		SOSZ_thread(MODE_NORMAL);
		Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), s1);

		SOSZ_thread(MODE_NORMAL);
		Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), s2);

		SOSZ_thread(MODE_NORMAL);
		Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), s2);
	}
}
void Test_SO_pulseOnOff_end(enum Active_state s1)
{
	SOSZ_thread(MODE_NORMAL);
	Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), s1);
}
void Test_SO_pulseOnOff(void)
{
/* Init */
	Test_SO_pulseOnOff_setup();

/* Test */

	// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(1<<0);

	Test_SO_pulseOnOff_cycle(3, PULSE_ON, PULSE_OFF);

	Test_SO_pulseOnOff_end(STEADY_ON);
}
struct cycleSO_t {
	BYTE active;
	struct cycleSO_t * next;
	enum SO_objectType objType;
	enum SO_objectNumber objNum;
	enum Active_state state;
};
#define SO_CYCLE_ARRAY_SIZE 7//8
struct cycleSO_t cycleSO [SO_CYCLE_ARRAY_SIZE];
void cycleSO_init(void)
{
	memset((void *)&cycleSO[0], 0, sizeof(cycleSO));
}
int cycleSO_add(BYTE reset, enum SO_objectType objType, enum SO_objectNumber objNum, enum Active_state state)
{
	struct cycleSO_t * curr = &cycleSO[0];
	struct cycleSO_t * last = &cycleSO[0];
	BYTE i=0;
	if (reset)
	{
		cycleSO_init();
	}
	if (curr->active != 0)
	{
		while (curr->next != 0)
		{
			if (i++ > SO_CYCLE_ARRAY_SIZE) {
				Test_failureTrap();
				return -1;
			}
			last = curr;
			curr = curr->next;
		} ;
		curr->next = &cycleSO[i+1];
		last = curr->next;
	}
	else {
		last->next = (struct cycleSO_t *)0;
	}
	last->active = 1;
	last->objNum = objNum;
	last->objType = objType;
	last->state = state;

	return 1;
}
void Test_SO_cycleSOthreadOnly(int numCycles)
{
	struct cycleSO_t * curr = &cycleSO[0];
	int i;
	for (i=0; i<numCycles; i++) // 10
	{
		SOSZ_thread(MODE_NORMAL);
		curr = &cycleSO[0];
		while (curr != 0)
		{
			Test_verifyUint8(SOSZ_test_getActiveState(curr->objType, curr->objNum), curr->state);
			curr = curr->next;
		}
	}
}
void Test_SO_testShellPulseOnOffDelayOnDelayOff(void)
{
/* Init */
	SOSZ_init();

	struct SO * pSO = SOSZ_testGetSoPtr(SO_OBJ_1, SO_T_SO);
	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0xFF); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE siHi, BYTE siLo)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0x10, 0);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 0, 0, 0, 50*2, 40*2);

	Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), IDLE);

	pSO = SOSZ_testGetSoPtr(SO_OBJ_1, SO_T_SZ);

	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0xFF); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE siHi, BYTE siLo)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, 1);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 10, 24, 0, 0, 0);

	Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), IDLE_ACTIVE);
	Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), IDLE);

/* Test */

// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(1<<0);

	cycleSO_add(1, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_1, TURN_ON_DELAY);
	Test_SO_cycleSOthreadOnly(10);

	cycleSO_add(1, SO_T_SO, SO_OBJ_1, PULSE_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	Test_SO_cycleSOthreadOnly(50);

	cycleSO_add(1, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	Test_SO_cycleSOthreadOnly(40); // 40 + 60 = 100

	cycleSO_add(1, SO_T_SO, SO_OBJ_1, PULSE_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	Test_SO_cycleSOthreadOnly(50); // 50 + 100 = 150

	cycleSO_add(1, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	Test_SO_cycleSOthreadOnly(40); // 40 + 150 = 190

	cycleSO_add(1, SO_T_SO, SO_OBJ_1, PULSE_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	Test_SO_cycleSOthreadOnly(50); // 50 + 190 = 240

	cycleSO_add(1, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	Test_SO_cycleSOthreadOnly(10); // 10 + 240 = 250

	cycleSO_add(1, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_1, TURN_OFF_DELAY);
	Test_SO_cycleSOthreadOnly(30); // 30 + 250 = 280

	SOSZ_thread(MODE_NORMAL);
	Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SO, SO_OBJ_1), IDLE_ACTIVE);
	Test_verifyUint8(SOSZ_test_getActiveState(SO_T_SZ, SO_OBJ_1), TURN_OFF_DELAY);
}
void Test_SO_testShellPulseOnOffDelayOnDelayOffFull(void)
{
/* Init */
	SOSZ_init();

/* Config SO 1 */
	struct SO * pSO = SOSZ_testGetSoPtr(SO_OBJ_1, SO_T_SO);
	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0xFF); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE siHi, BYTE siLo)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0x30, 0);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 0, 0, 0, 50*2, 40*2);

/* Config SZ 1 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_1, SO_T_SZ);

	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0x71); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, 0x03);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 10, 24, 0, 0, 0);

/* Config SZ 2 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_2, SO_T_SZ);

	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0x71); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
#define sz3mask 0x40
	SOSZ_test_setTermX(pSO, 1, 0, 0, sz3mask, 0);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 180, 23, 0, 0, 0);

/* Config SZ 3 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_3, SO_T_SZ);

	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0x71); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE siHi, BYTE siLo)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, 0x03);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 240, 0, 0, 0, 0);


/* Test */
	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(1);

// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(1<<0);

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(10); // 0 to 10

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_ON);
	Test_SO_cycleSOthreadOnly(50); // 10 to 60
	LED_updateTimer();
	LED_thread();

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(40); // 60 to 100
	LED_updateTimer();
	LED_thread();

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_ON);
	Test_SO_cycleSOthreadOnly(50); // 100 to 150

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(40); // 150 to 190

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_ON);
	Test_SO_cycleSOthreadOnly(50); // 190 to 240

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(1); // 240 to 241

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(9); // 241 to 250

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(30); // 250 to 280

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(141); // 280 to 421

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_ON);
	Test_SO_cycleSOthreadOnly(50); // 420 to 470

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(40); // 470 to 510

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_ON);
	Test_SO_cycleSOthreadOnly(50); // 510 to 560

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(40); // 560 to 600

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_ON);
	Test_SO_cycleSOthreadOnly(50); // 600 to 650

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(20); // 650 to 670

// Clear Alarm
	SOSZ_clearSOSZ_SILoAlm(1<<0);

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, TURN_OFF_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(1); // 650 to 670

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, PULSE_OFF);
	Test_SO_cycleSOthreadOnly(19); // 650 to 670

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_2, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_3, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(10); // 660 to 670

}
void test_so_2xIssue(void)
{
	unsigned int i = 0;
	LED_setMode(MODE_NORMAL);
	SOSZ_notifySOSZ_SILoAlm(1<<0);
	for (i=0; i<132; i++)
	{
		SOSZ_thread(MODE_NORMAL);
		LED_test_marshalLEDperI2CportSOREL();
		Fault_testThread();
	}
	SOSZ_clearSOSZ_SILoAlm(1<<0);
	SOSZ_thread(MODE_NORMAL);
	LED_test_marshalLEDperI2CportSOREL();
	Fault_testThread();

	SOSZ_notifySOSZ_SILoAlm(1<<0);
	for (i=0; i<132; i++)
	{
		SOSZ_thread(MODE_NORMAL);
		LED_test_marshalLEDperI2CportSOREL();
		Fault_testThread();
	}
}
void test_so_2xIssueIsolated(void)
{
	LED_setRate(LED_SO_1_Alm, RATE_ON);
	LED_setRate(LED_SO_5_Alm, RATE_ON);
	LED_test_marshalLEDperI2CportSOREL();
	LED_test_marshalLEDperI2CportSOREL();
	LED_setRate(LED_SO_1_Alm, RATE_OFF);
	LED_setRate(LED_SO_5_Alm, RATE_OFF);
	LED_test_marshalLEDperI2CportSOREL();
	LED_test_marshalLEDperI2CportSOREL();
	LED_setRate(LED_SO_1_Alm, RATE_ON);
	LED_setRate(LED_SO_5_Alm, RATE_ON);
	LED_test_marshalLEDperI2CportSOREL();
	LED_test_marshalLEDperI2CportSOREL();
}
void Test_SO_siHighAndSzHigh_setup(struct SO * pSO)
{
	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0x71); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 10, 24, 0, 0, 0);
}
void Test_SO_andOrAbort_setup(BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off, BYTE abort)
{
#define SI1mask 0x01
#define SI4mask 0x08
	/* Init */
	SOSZ_init();

	struct SO * pSO;

	BYTE *pAbortTimer = (BYTE *)&pConfigMemRAM->xabort.AbortTimer;
	*pAbortTimer = abort;

	/* Config SZ 1 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_1, SO_T_SO);
	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
#define abort_SI4  3 // SI_1 -> 000, SI_2 -> 001, SI_3 -> 010, SI_4 = 011 = 3
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOrAbort, abort_SI4);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0x71); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, SI1mask);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, turnOn, turnOff, per, on, off);
}
void Test_SO_testOneObject(enum objectType type, enum objectNumber num, enum Active_state state, enum objectStatus status, uint16_t cycles)
{
	cycleSO_add(1, (enum SO_objectType)type, (enum SO_objectNumber)num, state);
	Test_SO_cycleSOthreadOnly(cycles);
	Test_verifyUint8(SO_objStatus(type, num), status);
}
void Test_SO_andOrAbort_noTimers_idle_setAlm_toSteadyOn(void)
{
/* Init and Config */
	// Test_SO_andOrAbort_setup(BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	Test_SO_andOrAbort_setup(0, 0, 0, 0, 0, 30);

/* Test */
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(SI1mask);
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, STEADY_ON, OBJ_S_ACTIVE, 1);
}
void Test_SO_andOrAbort_noTimers_steadyOn_abortHasNoEffect(void)
{
	Test_SO_andOrAbort_noTimers_idle_setAlm_toSteadyOn();
	// Set Abort
	SOSZ_notifySOSZ_SILoAlm(SI4mask);
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, STEADY_ON, OBJ_S_ACTIVE, 1);
}
void Test_SO_andOrAbort_noTimers_idle_abortThenAlarm_toAbortWaitForRelease(void)
{
/* Init and Config */
	// Test_SO_andOrAbort_setup(BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	Test_SO_andOrAbort_setup(0, 0, 0, 0, 0, 30);

/* Test */
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Abort
	SOSZ_notifySOSZ_SILoAlm(SI4mask);
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(SI1mask);
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_WAIT_FOR_RELEASE, OBJ_S_INACTIVE, 1);
}
void Test_SO_andOrAbort_noTimers_abortWaitForRelease_releaseAbortAlmPresent_toSteadyOn(void)
{
	Test_SO_andOrAbort_noTimers_idle_abortThenAlarm_toAbortWaitForRelease();
	// Relase abort
	SOSZ_clearSOSZ_SILoAlm(SI4mask);
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, STEADY_ON, OBJ_S_ACTIVE, 1);
}
void Test_SO_andOrAbort_noTimers_abortWaitForRelease_clearAlm_toIdle(void)
{
	Test_SO_andOrAbort_noTimers_idle_abortThenAlarm_toAbortWaitForRelease();

	// Clear alarm
	SOSZ_clearSOSZ_SILoAlm(SI1mask);
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);
}
void Test_SO_andOrAbort_noTimers_steadyOn_abortDuringHasNoEffect(void)
{
/* Init and Config */
	// Test_SO_andOrAbort_setup(BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	Test_SO_andOrAbort_setup(0, 0, 0, 0, 0, 30);

/* Test */
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(SI1mask);
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, STEADY_ON, OBJ_S_ACTIVE, 1);

	// Set Abort
	SOSZ_notifySOSZ_SILoAlm(SI4mask);
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, STEADY_ON, OBJ_S_ACTIVE, 1);
}
void Test_SO_andOrAbort_delayOnTimerOnly_idle_setAlm_toDelayOn(void)
{
/* Init and Config */
	// Test_SO_andOrAbort_setup(BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	Test_SO_andOrAbort_setup(10, 0, 0, 0, 0, 20);

/* Test */
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(SI1mask);

	// Verify transition to TURN_ON_DELAY
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, TURN_ON_DELAY, OBJ_S_INACTIVE, 1); // 1 of 10
}
void Test_SO_andOrAbort_delayOnTimerOnly_delayOn_setAbort_toAbortDelayOnActive(void)
{
	Test_SO_andOrAbort_delayOnTimerOnly_idle_setAlm_toDelayOn();

	// Set Abort
	SOSZ_notifySOSZ_SILoAlm(SI4mask);

	// cycle down turnOn + abort
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_ACTIVE, OBJ_S_INACTIVE, 1); // 20 (abort) added to 10 delay On, so 2 of 30
}
void Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnActive_abortReleased_toAbortDelayOnReleased(void)
{
	Test_SO_andOrAbort_delayOnTimerOnly_delayOn_setAbort_toAbortDelayOnActive();

	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_ACTIVE, OBJ_S_INACTIVE, 1); // 3 of 30

	// Relase abort, then countdown
	SOSZ_clearSOSZ_SILoAlm(SI4mask);

	// Verify state transition
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_RELEASED, OBJ_S_INACTIVE, 1); // 4 of 30
}
void Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnReleased_countdown_toSteadyOn(void)
{
	Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnActive_abortReleased_toAbortDelayOnReleased();

	// Countdown
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_RELEASED, OBJ_S_INACTIVE, 26); // 26 of 30

	// Verify final state transition
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, STEADY_ON, OBJ_S_ACTIVE, 26);
}
void Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnActive_countdown_toAbortWaitForRelease(void)
{
	Test_SO_andOrAbort_delayOnTimerOnly_delayOn_setAbort_toAbortDelayOnActive();

	// Countdown
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_ACTIVE, OBJ_S_INACTIVE, 28);

	// Verify final state transition
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_WAIT_FOR_RELEASE, OBJ_S_INACTIVE, 26);
}
void Test_SO_andOrAbort_delayOnTimerOnly_abortWaitForRelease_abortReleased_toSteadyOn(void)
{
	Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnActive_countdown_toAbortWaitForRelease();

	// Relase abort, then countdown
	SOSZ_clearSOSZ_SILoAlm(SI4mask);

	// Verify state transition
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, STEADY_ON, OBJ_S_ACTIVE, 1);
}
void Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_idle_setAbortThenAlm_toAbortDelayOnActive(void)
{
/* Init and Config */
	// Test_SO_andOrAbort_setup(BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	Test_SO_andOrAbort_setup(10, 0, 0, 0, 0, 20);

/* Test */
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Abort
	SOSZ_notifySOSZ_SILoAlm(SI4mask);

	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(SI1mask);

	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_ACTIVE, OBJ_S_INACTIVE, 1);
}
void Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnActive_releaseAbort_toAbortDelayOnReleased(void)
{
	Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_idle_setAbortThenAlm_toAbortDelayOnActive();

	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_ACTIVE, OBJ_S_INACTIVE, 1); // 3 of 10

	// Relase abort, then countdown
	SOSZ_clearSOSZ_SILoAlm(SI4mask);

	// Verify state transition
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_RELEASED, OBJ_S_INACTIVE, 1); // 4 of 10
}
void Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnReleased_countdown_toSteadyOn(void)
{
	Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnActive_releaseAbort_toAbortDelayOnReleased();

	// Countdown
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_RELEASED, OBJ_S_INACTIVE, 7);//6); // 6 of 10

	// Verify final state transition
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, STEADY_ON, OBJ_S_ACTIVE, 6);
}
void Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnActive_countdown_toAbortWaitForRelease(void)
{
	Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_idle_setAbortThenAlm_toAbortDelayOnActive();

	// Countdown
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_ACTIVE, OBJ_S_INACTIVE, 9);//8);

	// Verify final state transition
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_WAIT_FOR_RELEASE, OBJ_S_INACTIVE, 8);
}
void Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortWaitForRelease_abortReleased_toSteadyOn(void)
{
	Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnActive_countdown_toAbortWaitForRelease();

	// Relase abort, then countdown
	SOSZ_clearSOSZ_SILoAlm(SI4mask);

	// Verify state transition
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, STEADY_ON, OBJ_S_ACTIVE, 1);
}
void Test_SO_andOrAbort_pulseOnOff_idle_setAlm_toPulseOn(void)
{
/* Init and Config */
	// Test_SO_andOrAbort_setup(BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	Test_SO_andOrAbort_setup(0, 0, 10, 4, 4, 20);

/* Test */
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(SI1mask);

	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, PULSE_ON, OBJ_S_ACTIVE, 1);

}
void Test_SO_andOrAbort_pulseOnOff_pulseOn_abortHasNoEffect(void)
{
	Test_SO_andOrAbort_pulseOnOff_idle_setAlm_toPulseOn();

	// Set Abort
	SOSZ_notifySOSZ_SILoAlm(SI4mask);

	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, PULSE_ON, OBJ_S_ACTIVE, 1);
}
void Test_SO_andOrAbort_pulseOnOff_pulseOn_countdown_toPulseOff(void)
{
	Test_SO_andOrAbort_pulseOnOff_idle_setAlm_toPulseOn();

	// Countdown
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, PULSE_ON, OBJ_S_ACTIVE, 1);
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, PULSE_OFF, OBJ_S_INACTIVE, 1);
}
void Test_SO_andOrAbort_pulseOnOff_pulseOff_abortHasNoEffect(void)
{
	Test_SO_andOrAbort_pulseOnOff_pulseOn_countdown_toPulseOff();

	// Set Abort
	SOSZ_notifySOSZ_SILoAlm(SI4mask);

	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, PULSE_OFF, OBJ_S_INACTIVE, 1);
}
void Test_SO_andOrAbort_pulseOnOff_abortFirst_idle_setAbortThenAlm_toAbortDelayOnActive(void)
{
/* Init and Config */
	// Test_SO_andOrAbort_setup(BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	Test_SO_andOrAbort_setup(0, 0, 10, 4, 4, 20);

/* Test */
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Abort
	SOSZ_notifySOSZ_SILoAlm(SI4mask);

	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, IDLE_ACTIVE, OBJ_S_INACTIVE, 1);

	// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(SI1mask);

	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, ABORT_TURN_ON_ACTIVE, OBJ_S_INACTIVE, 1);
}
void Test_SO_andOrAbort_pulseOnOff_abortFirst_abortDelayOnActive_abortReleasedToPulseOn(void)
{
	Test_SO_andOrAbort_pulseOnOff_abortFirst_idle_setAbortThenAlm_toAbortDelayOnActive();

	// Relase abort
	SOSZ_clearSOSZ_SILoAlm(SI4mask);

	// Verify state transition
	Test_SO_testOneObject(OBJ_T_SO, OBJ_1, PULSE_ON, OBJ_S_ACTIVE, 1);
}
void Test_SO_normallyOn(void)
{
#define SI1mask 0x01
#define SI4mask 0x08

/* Init */
	init();
	init_system();
	struct SO * pSO;

/* Config SO 1 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_1, SO_T_SO);

	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 1, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, SI1mask);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 0, 0, 0, 0, 0);

/* Config SO 1 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_2, SO_T_SO);

	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, SI1mask);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 0, 0, 0, 0, 0);

	SO_FWS_setSoMode(SO_T_SO, SO_OBJ_1, SO_MODE_SO);  // override normal SO_MODE_FWS
	SO_FWS_setSoMode(SO_T_SO, SO_OBJ_2, SO_MODE_SO);  // override normal SO_MODE_FWS

	Fault_init();
	SOSZ_updateSOSZ_SOnormalState();
	Test_verifyUint8(SOSZ_getSOSZ_SOnormalState(), 0x01);

/* Test */
	int i;
	cycleSO_add(1, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SO, SO_OBJ_2, IDLE_ACTIVE);
	for (i=0; i<=101; i++)
	{
		Test_SO_cycleSOthreadOnly(1);
		Fault_updateTimer();
		Fault_thread();
		LED_updateTimer();
		LED_thread();
		Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_1), OBJ_S_INACTIVE);
		Test_verifyUint8(LED_getRate(LED_SO_1_Alm), RATE_OFF);
		Test_verifyUint8(LED_getRate(LED_SO_1_Flt), RATE_OFF);
		Test_verifyUint8(LED_getRate(LED_SO_2_Alm), RATE_OFF);
		Test_verifyUint8(LED_getRate(LED_SO_2_Flt), RATE_OFF);
	}

	// Set SI1, both active -- turn on SO_1
	SOSZ_notifySOSZ_SILoAlm(SI1mask);


	cycleSO_add(1, SO_T_SO, SO_OBJ_1, STEADY_ON);
	cycleSO_add(0, SO_T_SO, SO_OBJ_2, STEADY_ON);
	for (i=0; i<=101; i++)
	{
		Test_SO_cycleSOthreadOnly(1);
		Fault_updateTimer();
		Fault_thread();
		LED_updateTimer();
		LED_thread();
		Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_1), OBJ_S_ACTIVE);
		Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_2), OBJ_S_ACTIVE);
		Test_verifyUint8(LED_getRate(LED_SO_1_Alm), RATE_ON);
		Test_verifyUint8(LED_getRate(LED_SO_1_Flt), RATE_OFF);
		Test_verifyUint8(LED_getRate(LED_SO_2_Alm), RATE_ON);
		Test_verifyUint8(LED_getRate(LED_SO_2_Flt), RATE_OFF);
	}

	// Clear SI1, SI4 still active -- SO_1 should turn off since it has no timers set
	SOSZ_clearSOSZ_SILoAlm(SI1mask);
	cycleSO_add(1, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SO, SO_OBJ_2, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(1);
	Fault_updateTimer();
	Fault_thread();
	LED_updateTimer();
	LED_thread();
	Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_1), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_2), OBJ_S_INACTIVE);
	Test_verifyUint8(LED_getRate(LED_SO_1_Alm), RATE_OFF);
	Test_verifyUint8(LED_getRate(LED_SO_1_Flt), RATE_OFF);
	Test_verifyUint8(LED_getRate(LED_SO_2_Alm), RATE_OFF);
	Test_verifyUint8(LED_getRate(LED_SO_2_Flt), RATE_OFF);
}
void Test_SO_andOr_verifyAndLogic(void)
{
#define SI1mask 0x01
#define SI4mask 0x08

/* Init */
	SOSZ_init();
	struct SO * pSO;

/* Config SO 1 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_1, SO_T_SO);

	//  void SOSZ_test_setConfigA(struct SO *p, BYTE normOn, BYTE inhibit, BYTE outputCtl, BYTE abort)
	SOSZ_test_setConfigA(pSO, 0, 0, SO_configByte_OutputControl_andOr, 0);

	//  void SOSZ_test_setOps(struct SO *p, BYTE termMask)
	SOSZ_test_setOps(pSO, 0); // MSB unused, LSB Term1Op, 1=or, 0=and

	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, SI1mask+SI4mask);
	SOSZ_test_setTermX(pSO, 2, 0, 0, 0, 0);//0x02);
	SOSZ_test_setTermX(pSO, 3, 0, 0, 0, 0);
	SOSZ_test_setTermX(pSO, 4, 0, 0, 0, 0);

	//  void SOSZ_test_setTimers(struct SO *p, BYTE turnOn, BYTE turnOff, BYTE per, BYTE on, BYTE off)
	SOSZ_test_setTimers(pSO, 0, 0, 0, 0, 0);

/* Test */
	cycleSO_add(1, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(1);
	Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_1), OBJ_S_INACTIVE);

	// Set Alarm
	SOSZ_notifySOSZ_SILoAlm(SI1mask);
	SOSZ_clearSOSZ_SILoAlm(SI4mask);
	cycleSO_add(1, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(1);
	Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_1), OBJ_S_INACTIVE);

	// Clear SI1, set SI4 -- SO_1 not on
	SOSZ_clearSOSZ_SILoAlm(SI1mask);
	SOSZ_notifySOSZ_SILoAlm(SI4mask);
	cycleSO_add(1, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(1);
	Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_1), OBJ_S_INACTIVE);

	// Set SI1, both active -- turn on SO_1
	SOSZ_notifySOSZ_SILoAlm(SI1mask);
	SOSZ_notifySOSZ_SILoAlm(SI4mask);
	cycleSO_add(1, SO_T_SO, SO_OBJ_1, STEADY_ON);
	Test_SO_cycleSOthreadOnly(1);
	Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_1), OBJ_S_ACTIVE);

	// Clear SI1, SI4 still active -- SO_1 should turn off since it has no timers set
	SOSZ_clearSOSZ_SILoAlm(SI1mask);
	SOSZ_notifySOSZ_SILoAlm(SI4mask);
	cycleSO_add(1, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(1);
	Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_1), OBJ_S_INACTIVE);

	// Clear SI1 and SI4 -- SO_1 should turn off since it has no timers set
	SOSZ_clearSOSZ_SILoAlm(SI1mask);
	SOSZ_clearSOSZ_SILoAlm(SI4mask);
	cycleSO_add(1, SO_T_SO, SO_OBJ_1, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(1);
	Test_verifyUint8(SO_objStatus(OBJ_T_SO, OBJ_1), OBJ_S_INACTIVE);
}
void Test_SO_siHighAndSzHigh(void)
{
/* Init */
	SOSZ_init();

#define SI1mask 0x01
#define SI4mask 0x08
#define SI5mask 0x10
#define SI8mask 0x80
#define SI9mask 0x01
#define SI12mask 0x08

	struct SO * pSO;

/* Config SZ 1 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_1, SO_T_SZ);
	Test_SO_siHighAndSzHigh_setup(pSO);
	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, SI1mask);
/* Config SZ 4 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_4, SO_T_SZ);
	Test_SO_siHighAndSzHigh_setup(pSO);
	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, SI1mask);
/* Config SZ 5 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_5, SO_T_SZ);
	Test_SO_siHighAndSzHigh_setup(pSO);
	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, SI1mask);
/* Config SZ 8 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_8, SO_T_SZ);
	Test_SO_siHighAndSzHigh_setup(pSO);
	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, 0, SI1mask);
/* Config SZ 9 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_9, SO_T_SZ);
	Test_SO_siHighAndSzHigh_setup(pSO);
	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, SI9mask, 0);
/* Config SZ 12 */
	pSO = SOSZ_testGetSoPtr(SO_OBJ_12, SO_T_SZ);
	Test_SO_siHighAndSzHigh_setup(pSO);
	//  void SOSZ_test_setTermX(struct SO *p, BYTE term, BYTE siWar, BYTE sz, BYTE sz4to1_si12to9, BYTE si8to1)
	SOSZ_test_setTermX(pSO, 1, 0, 0, SI9mask, 0);

/* Test */
	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_4, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_5, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_8, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_9, IDLE_ACTIVE);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_12, IDLE_ACTIVE);
	Test_SO_cycleSOthreadOnly(1);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_1), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_4), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_5), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_8), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_9), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_12), OBJ_S_INACTIVE);

// Set Alarm
	SOSZ_notifySOSZ_SIHiAlm(SI9mask);
	SOSZ_notifySOSZ_SILoAlm(SI1mask);

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_4, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_5, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_8, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_9, TURN_ON_DELAY);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_12, TURN_ON_DELAY);
	Test_SO_cycleSOthreadOnly(10); // 0 to 10
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_1), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_4), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_5), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_8), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_9), OBJ_S_INACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_12), OBJ_S_INACTIVE);

	cycleSO_add(1, SO_T_SZ, SO_OBJ_1, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_4, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_5, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_8, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_9, STEADY_ON);
	cycleSO_add(0, SO_T_SZ, SO_OBJ_12, STEADY_ON);
	Test_SO_cycleSOthreadOnly(50);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_1), OBJ_S_ACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_4), OBJ_S_ACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_5), OBJ_S_ACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_8), OBJ_S_ACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_9), OBJ_S_ACTIVE);
	Test_verifyUint8(SO_objStatus(OBJ_T_SZ, OBJ_12), OBJ_S_ACTIVE);
}
void Test_SO(void)
{
//	Test_SO_outputTrigger_andOr();
//	Test_SO_outputTrigger_ga();

	Test_SO_andOr_verifyAndLogic();
	Test_SO_normallyOn();
    test_so_2xIssue();

	Test_SO_pulseOnOff();
	Test_SO_testShellPulseOnOffDelayOnDelayOff();
	Test_SO_siHighAndSzHigh();
	Test_SO_testShellPulseOnOffDelayOnDelayOffFull();

	/*
	 * o no timers
	 * 		x 1. alarm first -> STEADY_ON, then abort -> STEADY_ON
	 * 		x 2. abort first, then alarm -> ABORT_WAIT_FOR_RELEASE
	 * 		x 3. Test 2, then release abort -> STEADY_ON
	 */
	Test_SO_andOrAbort_noTimers_idle_setAlm_toSteadyOn();
	Test_SO_andOrAbort_noTimers_steadyOn_abortHasNoEffect();
	Test_SO_andOrAbort_noTimers_idle_abortThenAlarm_toAbortWaitForRelease();
	Test_SO_andOrAbort_noTimers_abortWaitForRelease_releaseAbortAlmPresent_toSteadyOn();
	Test_SO_andOrAbort_noTimers_abortWaitForRelease_clearAlm_toIdle();
	Test_SO_andOrAbort_noTimers_steadyOn_abortDuringHasNoEffect();

	/* 1 Test_SO_andOrAbort_delayOnTimerOnly_idle_setAlm_toDelayOn()
	 * 2 Test_SO_andOrAbort_delayOnTimerOnly_delayOn_setAbort_toAbortDelayOnActive()
	 * 3 Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnActive_abortReleased_toAbortDelayOnReleased()
	 * 4 Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnReleased_countdown_toSteadyOn()
	 * 5 Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnActive_countdown_toAbortWaitForRelease()
	 *   Test_SO_andOrAbort_delayOnTimerOnly_abortWaitForRelease_abortReleased_toSteadyOn()
	 * o delay on set
	 * 		o 1. alarm first -> DELAY_ON
	 * 		o 2. Test 1, then abort during DELAY_ON --> ABORT_TURN_ON_ACTIVE, add abortTimer to remaining turnOnDelay
	 * 		o 3. Test 2, release abort during ABORT_TURN_ON_ACTIVE --> ABORT_TURN_ON_RELEASED
	 * 		o 4. Test 3, transition to STEADY_ON after abortTimer + turnOnDelay
	 * 		o 5. Test 2, hold abort during duration of ABORT_TURN_ON_ACTIVE, then --> ABORT_WAIT_FOR_RELEASE
	 * 		o 6. abort first, then alarm --> ABORT_TURN_ON_ACTIVE
	 * 		o 7. Test 6, release abort during abortDelayOnDelay timer --> ABORT_TURN_ON_RELEASED
	 * 		o 8. Test 7, countdown to end of delayOn --> STEADY_ON
	 * 		o 9. Test 6, hold abort through delayOn timer --> ABORT_WAIT_FOR_RELEASE
	 * 		o 10. Test 9, relase abort --> STEADY_ON
	 * 6 Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_idle_setAbortThenAlm_toAbortDelayOnActive
	 * 7 Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnActive_releaseAbort_toAbortDelayOnReleased
	 * 8 Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnReleased_countdown_toSteadyOn
	 * 9 Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnActive_countdown_toAbortWaitForRelease
	 * 10 Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortWaitForRelease_abortReleased_toSteadyOn
	 */
	Test_SO_andOrAbort_delayOnTimerOnly_idle_setAlm_toDelayOn();
	Test_SO_andOrAbort_delayOnTimerOnly_delayOn_setAbort_toAbortDelayOnActive(); // pass
	Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnActive_abortReleased_toAbortDelayOnReleased(); // pass
	Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnReleased_countdown_toSteadyOn(); // pass
	Test_SO_andOrAbort_delayOnTimerOnly_abortDelayOnActive_countdown_toAbortWaitForRelease(); // pass
	Test_SO_andOrAbort_delayOnTimerOnly_abortWaitForRelease_abortReleased_toSteadyOn(); // pass

	Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_idle_setAbortThenAlm_toAbortDelayOnActive(); // pass
	Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnActive_releaseAbort_toAbortDelayOnReleased(); // pass
	Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnReleased_countdown_toSteadyOn(); // pass
	Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortDelayOnActive_countdown_toAbortWaitForRelease(); // pass
	Test_SO_andOrAbort_delayOnTimerOnly_abortFirst_abortWaitForRelease_abortReleased_toSteadyOn(); // pass
	 /* o pulse on/off set
	 * 		o 1.
	 */
	Test_SO_andOrAbort_pulseOnOff_idle_setAlm_toPulseOn();
	Test_SO_andOrAbort_pulseOnOff_pulseOn_abortHasNoEffect();
	Test_SO_andOrAbort_pulseOnOff_pulseOn_countdown_toPulseOff();
	Test_SO_andOrAbort_pulseOnOff_pulseOff_abortHasNoEffect();
	Test_SO_andOrAbort_pulseOnOff_abortFirst_idle_setAbortThenAlm_toAbortDelayOnActive();
	Test_SO_andOrAbort_pulseOnOff_abortFirst_abortDelayOnActive_abortReleasedToPulseOn();
}
void Test_GA_setupGA(BYTE silenceInAlert, BYTE preAlertTimer, BYTE alertTimer, BYTE alertOn, BYTE alertOff, BYTE evacMin, BYTE autoSilence)
{
	struct GA * pGAcfg = (struct GA *)&pConfigMemRAM->ga;
	pGAcfg->GAEnableSilence = silenceInAlert;
	pGAcfg->PreAlertTimer = preAlertTimer;
	pGAcfg->AlertTimer = alertTimer;
	pGAcfg->GAAlertOnTimer = alertOn;
	pGAcfg->GAAlertOffTimer = alertOff;
	pGAcfg->EvacMinTimer = evacMin;
	pGAcfg->AutoSilenceTimer = autoSilence;
	GA_init();
	Test_GA_testResult(0);
}
void Test_GA_preBasicSetup(void)
{
	/*------------------------------------------------------*/
	/* 			Setup 										*/
	/*------------------------------------------------------*/

	SO_out_init();

	Buzzer_init();
	BTN_init();

	SI_init();
	SOSZ_init();
	Fault_init();
	Relay_init();
	GA_init();
	I2CioDriver_init();
	LED_init();
//		init_system();

}
void Test_GA_basicSetup(enum SI_X siMe, enum SI_X siMe2)
{
	Test_GA_preBasicSetup();

	/* Setup GA silence during Alert = disabled, all timers set to zero*/
	Test_GA_setupGA((BYTE)silenceInAlertDisabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_0, GA_TIMER_ALERT_ON_0, GA_TIMER_ALERT_OFF_0, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_0);

	/* Set SI_1 for Normal GA, set all timers to 0*/
//	enum SI_X siMe = SI_1;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	Test_SI_SH_loadSI1NonLatchNoTimerGA(siMe);
	struct SI_threadInfo_t * pSI_threadInfo2 = SI_rtnThreadInfo(siMe2);
	Test_SI_SH_loadSI1NonLatchNoTimerGA(siMe2);


	SOSZ_test_GAfxnSO(SO_OBJ_1, SO_T_SO);

	LED_setRateRange(LED_Begin, LED_end, RATE_OFF);
	SI_threadInfo_reset(pSI_threadInfo);
	SI_threadInfo_reset(pSI_threadInfo2);
	Test_SI_clearButtonEvents();
}
void Test_GA_testResult(/*enum SI_X siMe, */WORD testNum)
{
//	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	struct Test_GA_result_t * pTest = &gaTestResultTable[testNum];

	SOSZ_thread(MODE_NORMAL);
	LED_resourceArray_processLED();

	// Verify Results
//	Test_SI_verifyState(pSI_threadInfo->alarmState, pTest->siStateFinal);
//	Test_SI_SH_verifyOutputs(pTest->siStateFinal, siMe);
	Test_verifyUint8(GA_statusForSOSZ(), pTest->gaOutputStatus);
	Test_verifyUint8( GA_getIsSilenced(), pTest->gaSilence);
	Test_verifyUint8( GA_getState(), pTest->gaState);
//	val = SOSZ_getSOSZ_SOtrigger();
//	Test_verifyUint8(val&(1<<pTest->soObjectNum), pTest->soszTriggerValue);
//	Test_verifyUint8( SOSZ_test_getEnabledState(pTest->soObjectType, pTest->soObjectNum), pTest->soEnabledState);
	Test_verifyUint8( LED_getRate(LED_GA_SILENCE), pTest->gaSilenceLedRate);
}
void Test_GA_testAfterInit(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);
	/*------------------------------------------------------*/
	/* Test Initial State
	 * GA SILENCE LED = OFF
	 * SX Output = OFF
	 * */
	/*------------------------------------------------------*/

	// Set Stimulus -- none
	pSI_threadInfo->adcState = SI_ADC_NORMAL;

	// Execute code
//	GA_thread();
	Test_SI_threadParams(siMe, SI_ADC_NORMAL, SI_STATE_IDLE, 100, SI_runMode_test, SI_runMode_test, 400);
	SOSZ_thread(MODE_NORMAL);
//	LED_resourceArray_processLED();

	// Verify Results
	Test_GA_testResult(0);
	Test_SI_verifyState(pSI_threadInfo->alarmState, SI_STATE_IDLE);
	Test_SI_SH_verifyOutputs(SI_STATE_IDLE, siMe);
	Test_verifyUint8(GA_statusForSOSZ(), GA_STATUS_OFF);
	Test_verifyUint8( GA_getIsSilenced(), NOT_SILENCED);
	Test_verifyUint8( GA_getState(), GA_NORMAL);
	val = SOSZ_getSOSZ_SOtrigger();
	Test_verifyUint8(val&(1<<SO_OBJ_1), 0);
	Test_verifyUint8( SOSZ_test_getEnabledState(SO_T_SO, SO_OBJ_1), IDLE);
	Test_verifyUint8( LED_getRate(LED_GA_SILENCE), RATE_OFF);
}
WORD GA_cycleTillState(enum eGA_States gaNextState, WORD timer)
{
	WORD tick = timer;
	do
	{
		GA_thread();
		if (gaNextState == GA_getState())
			break;
	} while (--tick != 0);
	return tick;
}
void Test_GA_preAlertOnly_setup(void)
{
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA((BYTE)silenceInAlertDisabled, GA_TIMER_PRE_ALERT_10, GA_TIMER_ALERT_0, GA_TIMER_ALERT_ON_0, GA_TIMER_ALERT_OFF_0, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_0);
}
void Test_GA_alertOnly_setup(BYTE silenceInAlert)
{
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA(silenceInAlert, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_12, GA_TIMER_ALERT_ON_2, GA_TIMER_ALERT_OFF_2, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_0);
}
void Test_GA_evacInhibitSilenceOnly_setup(void)
{
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA((BYTE)silenceInAlertDisabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_0, GA_TIMER_ALERT_ON_0, GA_TIMER_ALERT_OFF_0, GA_TIMER_EVAC_MIN_10, GA_TIMER_AUTO_SILENCE_0);
}
void Test_GA_evacInhibitSilenceAndAlert_setup(BYTE silenceInAlert)
{
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA(silenceInAlert, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_12, GA_TIMER_ALERT_ON_2, GA_TIMER_ALERT_OFF_2, GA_TIMER_EVAC_MIN_10, GA_TIMER_AUTO_SILENCE_0);
}
void Test_GA_evacAutoSilenceAndAlert_setup(BYTE silenceInAlert)
{
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA(silenceInAlert, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_12, GA_TIMER_ALERT_ON_2, GA_TIMER_ALERT_OFF_2, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_10);
}
void Test_GA_evacInhibitAndAutoSilence_setup(void)
{
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA(silenceInAlertDisabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_0, GA_TIMER_ALERT_ON_0, GA_TIMER_ALERT_OFF_0, GA_TIMER_EVAC_MIN_10, GA_TIMER_AUTO_SILENCE_2);
}
void Test_GA_evacAutoSilenceOnly_setup(void)
{
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA((BYTE)silenceInAlertDisabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_0, GA_TIMER_ALERT_ON_0, GA_TIMER_ALERT_OFF_0, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_10);
}
void Test_GA_allTimers_setup(void)
{
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA((BYTE)silenceInAlertDisabled, GA_TIMER_PRE_ALERT_10, GA_TIMER_ALERT_12, GA_TIMER_ALERT_ON_2, GA_TIMER_ALERT_OFF_2, GA_TIMER_EVAC_MIN_10, GA_TIMER_AUTO_SILENCE_10);
}
void Test_GA_notifyGA_SIalm(enum SI_X siMe, enum eGA_skipToEvac evac, enum Test_GA_id testNum)
{
	// Set Stimulus -- Set GA
	GA_notifyGA_SIalm(1<<siMe, evac);

	// Execute code
	GA_thread();

	// Verify Results -- verify in state
	Test_GA_testResult((WORD)testNum);
}
void Test_GA_clearGA_SIalm(enum SI_X siMe, enum Test_GA_id testNum)
{
	// Set Stimulus -- Clear GA
	GA_clearGA_SIalm(1<<siMe);

	// Execute code
	GA_thread();

	// Verify Results
	Test_GA_testResult(testNum);
}
void Test_GA_clearGAalm_thenSetGAoffBtn(enum SI_X siMe)
{

	/* Directly clear GA*/
	Test_GA_clearGA_SIalm(siMe, stEvac_gaOn_notSil_ledOff);

	/* Simulate press of GA OFF Btn, GA Silenced-*/
	BTN_btnEvent_testSet(eBtnGAoff, evt_yes);
	Test_verifyUint8( BTN_btnEvent_get(eBtnGAoff), evt_yes);
	GA_thread();
	Test_GA_testResult(stNorm_gaOn_notSil_ledOff);
}
void Test_GA_noTimersUseSI(enum SI_X siMe)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(siMe);

	Test_GA_basicSetup(siMe, SI_2);

	/* Test Initial State*/
	Test_GA_testAfterInit(siMe);
	Test_GA_testResult(0);

	/* Set GA via SI Alarm*/
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_GA_testResult(1);

	/* Simulate press of GA_OFF BUTTON, GA Silenced*/
	BTN_btnEvent_testSet(eBtnGAoff, evt_yes);
	Test_verifyUint8( BTN_btnEvent_get(eBtnGAoff), evt_yes);
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_GA_testResult(2);

	/* Simulate press of GA_ON BUTTON, GA back to Active*/
	BTN_btnEvent_testSet(eBtnGAon, evt_yes);
	Test_verifyUint8( BTN_btnEvent_get(eBtnGAon), evt_yes);
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_GA_testResult(3);
	Test_verifyUint8( BTN_btnEvent_get(eBtnGAoff), evt_no);
	Test_verifyUint8( BTN_btnEvent_get(eBtnGAon), evt_no);

	/* Clear SI Alarm, but GA still present because alarm hasn't been acked*/
	Test_SI_threadParams(siMe, SI_ADC_NORMAL, SI_STATE_alarmWaitForAck, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_GA_testResult(stEvac_gaOn_notSil_ledOff);//15);

	/* ACK-1 Alarm (non-latch) after clearing it...*/
	BTN_btnEvent_testSet(eBtnAck, evt_yes); // simulate ACK button press
	Test_SI_threadParams(siMe, SI_ADC_NORMAL, SI_STATE_alarmWaitForAck_afterResetOrFltClear, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_GA_testResult(stEvac_gaOn_notSil_ledOff);//16);//5);

	/* ACK-2 Alarm (non-latch) after clearing it...*/
	BTN_btnEvent_testSet(eBtnAck, evt_yes); // simulate ACK button press
	Test_SI_threadParams(siMe, SI_ADC_NORMAL, SI_STATE_IDLE, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_GA_testResult(stEvac_gaOn_notSil_ledOff);//17);//6);

	/* Simulate press of GA OFF Btn, GA Silenced-*/
	BTN_btnEvent_testSet(eBtnGAoff, evt_yes);
	Test_verifyUint8( BTN_btnEvent_get(eBtnGAoff), evt_yes);
	Test_SI_threadParams(siMe,  SI_ADC_NORMAL, SI_STATE_IDLE, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_GA_testResult(6);
}
enum testEvent {
	testEvent_countdown,
	testEvent_newAlarm,
	testEvent_loseAlarm,
	testEvent_gaOn,
	testEvent_gaOff
};
void Test_GA_countdownTemplate(enum Test_GA_id stateFinal, WORD cycles, WORD testCnt)
{
	/* Cycle through State delay to Evac --> GA_State = GA_EVAC, GA_Output = ON, GA_Silenced = false */
	val = GA_cycleTillState(GA_EVAC, cycles);
	Test_verifyUint8( val, testCnt); // verify countdown for state
	Test_GA_testResult(stateFinal);
}
void Test_GA_newAlmTemplate(enum Test_GA_id stateBeforeEvent, enum Test_GA_id stateAfterEvent)
{
	/* Cycle one more time through PreAlert */
	GA_thread();
	SOSZ_thread(MODE_NORMAL);
	Test_GA_testResult(stateBeforeEvent);
	
	/* Set second alarm, verify straight to evac */
	Test_GA_notifyGA_SIalm(SI_2, DO_NOT_SKIP_EVAC, stateAfterEvent);
}
void Test_GA_loseAlmTemplate(enum Test_GA_id stateAfterAlarm, enum Test_GA_id stateAfterEvent, enum Test_GA_id stateFinal, WORD cycles1, WORD cycles2, WORD testCnt)
{
	/* Cycle through halfway through, verify still in state */
	val = GA_cycleTillState(GA_EVAC, cycles1);
//	Test_verifyUint8( val, 0); // verify countdown for preAlert
	Test_GA_testResult(stateAfterAlarm);

	/* Directly clear GA, verify still in EvacInhSil state */
	Test_GA_clearGA_SIalm(SI_1, stateAfterEvent);

	/* Cycle through state delay to final state*/
	val = GA_cycleTillState(GA_EVAC, cycles2);
	Test_verifyUint8( val, testCnt); 
	Test_GA_testResult(stateFinal);
}
void Test_GA_gaOnTemplate(enum Test_GA_id stateAfterAlarm, enum Test_GA_id stateAfterEvent, enum Test_GA_id stateFinal, WORD cycles, WORD testCnt)
{
	/* Cycle one more time */
	GA_thread();
	Test_GA_testResult(stateAfterAlarm);

	/* Simulate press of GA_ON BUTTON, GA back to Active*/
	BTN_btnEvent_testSet(eBtnGAon, evt_yes);
	GA_thread();
	Test_GA_testResult(stateAfterEvent);

	/* Cycle through state delay to final state*/
	val = GA_cycleTillState(GA_EVAC, cycles);
	Test_verifyUint8( val, testCnt); 
	Test_GA_testResult(stateFinal);
}
void Test_GA_gaOffTemplate(enum Test_GA_id stateAfterAlarm, enum Test_GA_id stateAfterEvent, enum Test_GA_id stateFinal, WORD cycles, WORD testCnt)
{
	/* Cycle one more time */
	GA_thread();
	Test_GA_testResult(stateAfterAlarm);

	/* Simulate press of GA_OFF BUTTON, GA back to Active*/
	BTN_btnEvent_testSet(eBtnGAoff, evt_yes);
	GA_thread();
	Test_GA_testResult(stateAfterEvent);

	/* Cycle through PreAlert delay to Evac --> GA_State = GA_E, GA_Output = ON, GA_Silenced = false*/
	val = GA_cycleTillState(GA_EVAC, cycles);
	Test_verifyUint8( val, testCnt); // verify countdown for preAlert
	Test_GA_testResult(stateFinal);
}
void Test_GA_templateSetup(enum eGA_States initState, enum Test_GA_id stateAfterAlarm)
{
	/* 	Setup 		*/
	switch (initState)
	{	
		case GA_PRE_ALERT:
			Test_GA_preAlertOnly_setup();
			break;
		case GA_ALERT:
			Test_GA_alertOnly_setup(silenceInAlertDisabled);
			break;
		case GA_EVAC_INHIBIT_SILENCE:
			Test_GA_evacInhibitSilenceOnly_setup();
			break;
		case GA_EVAC_AUTO_SILENCE:
			Test_GA_evacAutoSilenceOnly_setup();
			break;
		case GA_NORMAL:
		case GA_EVAC:
			Test_GA_basicSetup(SI_1, SI_2);
			break;		
	}	
	/* Test state after alarm */
	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stateAfterAlarm);
}
void Test_GA_noTimersBypassSI(enum SI_X siMe )
{
	Test_GA_templateSetup(GA_NORMAL, stEvac_gaOn_notSil_ledOff);
	Test_GA_gaOffTemplate(stEvac_gaOn_notSil_ledOff, stEvac_gaOff_isSil_ledOn, stEvac_gaOff_isSil_ledOn, GA_TIMER_PRE_ALERT_10, 10);
	Test_GA_loseAlmTemplate(stEvac_gaOff_isSil_ledOn, stNorm_gaOn_notSil_ledOff, stNorm_gaOn_notSil_ledOff, GA_TIMER_PRE_ALERT_10>>2, GA_TIMER_PRE_ALERT_10, 0);
}
void Test_GA_preAlertOnly_countdown_PreAlertToEvac(enum SI_X siMe )
{
	Test_GA_templateSetup(GA_PRE_ALERT, stPreAlert_gaOff_notSil_ledOff);
	Test_GA_countdownTemplate(stEvac_gaOn_notSil_ledOff, GA_TIMER_PRE_ALERT_10, 1);
}
void Test_GA_preAlertOnly_loseAlmDuring_noEffectEndInEvac(enum SI_X siMe )
{
	Test_GA_templateSetup(GA_PRE_ALERT, stPreAlert_gaOff_notSil_ledOff);
	Test_GA_loseAlmTemplate(stPreAlert_gaOff_notSil_ledOff, stPreAlert_gaOff_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_TIMER_PRE_ALERT_10>>2, GA_TIMER_PRE_ALERT_10, 4);
}
void Test_GA_preAlertOnly_newAlmDuring_straightToEvac(void)
{
	Test_GA_templateSetup(GA_PRE_ALERT, stPreAlert_gaOff_notSil_ledOff);
	Test_GA_newAlmTemplate(stPreAlert_gaOff_notSil_ledOff, stEvac_gaOn_notSil_ledOff);
}
void Test_GA_preAlertOnly_gaOnDuring_turnsOnGAendInEvac(void)
{	
	Test_GA_templateSetup(GA_PRE_ALERT, stPreAlert_gaOff_notSil_ledOff);
	Test_GA_gaOnTemplate(stPreAlert_gaOff_notSil_ledOff, stPreAlert_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_TIMER_10-2, 1);
}
void Test_GA_preAlertOnly_gaOffDuring_hasNoEffectEndInEvac(void)
{
	Test_GA_templateSetup(GA_PRE_ALERT, stPreAlert_gaOff_notSil_ledOff);
	Test_GA_gaOffTemplate(stPreAlert_gaOff_notSil_ledOff, stPreAlert_gaOff_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_TIMER_PRE_ALERT_10, 3);
}
void Test_GA_alertCountDown(int loops, enum Test_GA_id st1, enum Test_GA_id st2, enum eGA_AlertOnOff out1, enum eGA_AlertOnOff out2)
{
	while (loops--)
	{
		// Execute code
		val = GA_cycleTillState(GA_EVAC, GA_TIMER_ALERT_ON_2);
//		Test_verifyUint8( val, 0); // verify countdown for preAlert
		Test_GA_testResult(st1);
		Test_verifyUint8( GA_getAlertOnOff(), out1);

		// Execute code
		val = GA_cycleTillState(GA_EVAC, GA_TIMER_ALERT_OFF_2);
//		Test_verifyUint8( val, 0); // verify countdown for preAlert
		Test_GA_testResult(st2);
		Test_verifyUint8( GA_getAlertOnOff(), out2);
	}
}
void Test_GA_alertOnly_countdown_silenceInAlertDisabled_endInEvacWithGaOn(enum SI_X siMe)
{
	Test_GA_templateSetup(GA_ALERT, stAlert_gaOn_notSil_ledOff);

	/* Cycle through Alert timer to Evac				*/
	Test_GA_alertCountDown(2, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
}
void Test_GA_alertOnly_invalidAlertOnOff_gaAlwaysOnDuring(void)
{
/* INVALID ALERT ON */
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA(silenceInAlertDisabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_12, GA_TIMER_ALERT_ON_0, GA_TIMER_ALERT_OFF_2, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_0);
	/* Test state after alarm */
	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stAlert_gaOn_notSil_ledOff);

	/* Cycle through Alert timer to Evac				*/
	Test_GA_alertCountDown(2, stAlert_gaOn_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_ON, GA_ALERT_ON);
	Test_GA_alertCountDown(1, stAlert_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_ALERT_ON, GA_ALERT_ON);

/* INVALID ALERT OFF */
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA(silenceInAlertDisabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_12, GA_TIMER_ALERT_ON_2, GA_TIMER_ALERT_OFF_0, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_0);
	/* Test state after alarm */
	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stAlert_gaOn_notSil_ledOff);

	/* Cycle through Alert timer to Evac				*/
	Test_GA_alertCountDown(2, stAlert_gaOn_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_ON, GA_ALERT_ON);
	Test_GA_alertCountDown(1, stAlert_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_ALERT_ON, GA_ALERT_ON);

/* INVALID ALERT */
	Test_GA_basicSetup(SI_1, SI_2);
	Test_GA_setupGA(silenceInAlertDisabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_0, GA_TIMER_ALERT_ON_2, GA_TIMER_ALERT_OFF_2, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_0);
	/* Test state after alarm */
	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stEvac_gaOn_notSil_ledOff);

	/* Cycle through Alert timer to Evac				*/
	Test_GA_countdownTemplate(stEvac_gaOn_notSil_ledOff, GA_TIMER_ALERT_12, 12);
}
void Test_GA_alertOnly_loseAlmDuring_endInNormalButStillCycling(void)
{
/*	------------------------------------------------------
	 			Setup
	------------------------------------------------------
	Test_GA_alertOnly_setup(silenceInAlertDisabled);

	------------------------------------------------------
	 			Test
	------------------------------------------------------

	------------------------------------------------------
	 Notify GA of Alarm --> GA_State = GA_PreAlert, GA_Output = OFF, GA_Silenced = false
	------------------------------------------------------

	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stAlert_gaOn_notSil_ledOff);

	------------------------------------------------------
	 Cycle part way through Alert delay, verify still in Alert
	------------------------------------------------------

	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff);

	------------------------------------------------------
	 Directly clear GA, verify still in Alert state
	------------------------------------------------------

	Test_GA_clearGA_SIalm(SI_1, stAlert_gaOn_notSil_ledOff);

	------------------------------------------------------
	 Cycle through Alert delay to Evac --> GA_State = GA_E, GA_Output = ON, GA_Silenced = false
	------------------------------------------------------

	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff);
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stEvac_gaOn_notSil_ledOff);*/
}
void Test_GA_alertOnly_loseAlmDuring_endInEvacGaOnNotSilenced(void)
{
	Test_GA_templateSetup(GA_ALERT, stAlert_gaOn_notSil_ledOff);

	/* Cycle one more time through Alert */
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);

	/* Directly clear GA, verify still in Alert state */
	Test_GA_clearGA_SIalm(SI_1, stAlert_gaOn_notSil_ledOff);

	/* Cycle through Alert delay to Evac --> GA_State = GA_E, GA_Output = ON, GA_Silenced = false */
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
}
void Test_GA_alertOnly_newAlmDuring_straightToEvac(void)
{
	Test_GA_templateSetup(GA_ALERT, stAlert_gaOn_notSil_ledOff);

	/* Cycle one more time through Alert */
	GA_thread();
	SOSZ_thread(MODE_NORMAL);
	Test_GA_testResult(stAlert_gaOn_notSil_ledOff);

	/* Set second alarm, verify straight to evac */
	GA_notifyGA_SIalm(SI_2m, DO_NOT_SKIP_EVAC);
	GA_thread();
	Test_GA_testResult(stEvac_gaOn_notSil_ledOff);
}
void Test_GA_alertOnly_newAlmDuring_straightToEvac_viaSI(void)
{
	Test_GA_alertOnly_setup(silenceInAlertDisabled);

	/* Set GA via SI Alarm*/
	Test_SI_threadParams(SI_1, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 100, SI_runMode_test, SI_runMode_test, 400);

	/* Test state after alarm */
//	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stateAfterAlarm);

	/* Cycle one more time through Alert */
//	GA_thread();
	Test_GA_testResult(stAlert_gaOn_notSil_ledOff);
//	Test_GA_testResult(stAlert_gaOff_notSil_ledOff);
	Test_verifyUint8(GA_getGA_SIalm(), (1<<SI_1));

	/* Clear? GA via SI Alarm*/
	Test_SI_threadParams(SI_1, SI_ADC_NORMAL, SI_STATE_alarmWaitForAck, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_verifyUint8(GA_getGA_SIalm(), 0);

/* QUESTION: DOES IT NEED AN ACK BEFORE THE GA IS CLEARED? */

	/* Cycle one more time through Alert */
	GA_thread();
	Test_GA_testResult(stAlert_gaOn_notSil_ledOff);
//	Test_GA_testResult(stAlert_gaOff_notSil_ledOff);
	Test_verifyUint8(GA_getGA_SIalm(), 0);

	/* Set GA via SI Alarm*/
	Test_SI_threadParams(SI_2, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_verifyUint8(GA_getGA_SIalm(), (1<<SI_2));

	/* Cycle one more time through Alert */
//	GA_thread();
//	Test_GA_testResult(stAlert_gaOn_notSil_ledOff);
	Test_GA_testResult(stAlert_gaOff_notSil_ledOff);

	/* Clear? GA via SI Alarm*/
	Test_SI_threadParams(SI_2, SI_ADC_NORMAL, SI_STATE_alarmWaitForAck, 100, SI_runMode_test, SI_runMode_test, 400);
	Test_verifyUint8(GA_getGA_SIalm(), 0);

	/* Cycle one more time through Alert */
//	GA_thread();
	Test_GA_testResult(stAlert_gaOn_notSil_ledOff);
//	Test_GA_testResult(stAlert_gaOff_notSil_ledOff);
//	Test_GA_testResult(stEvac_gaOn_notSil_ledOff);
//	Test_GA_testResult(stAlert_gaOff_notSil_ledOff);
}
void Test_GA_alertOnly_gaOnDuring_turnsOnGAendInEvacGaOn(void)
{
	Test_GA_templateSetup(GA_ALERT, stAlert_gaOn_notSil_ledOff);

	/* 		Cycle part way through Alert delay, verify still in Alert  	*/
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);

	/* 		Simulate GA_ON press, verify still in Alert state with GA ON*/
	BTN_btnEvent_testSet(eBtnGAon, evt_yes);
	Test_verifyUint8( BTN_btnEvent_get(eBtnGAon), evt_yes);

	/* 		Cycle through Alert delay to Evac --> GA_State = GA_E, GA_Output = ON, GA_Silenced = false 	*/
	Test_GA_alertCountDown(1, stAlert_gaOn_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
	Test_GA_alertCountDown(1, stAlert_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
}
void Test_GA_alertOnly_silenceInAlertEnabled_gaOffDuring_gaTurnsOffDuringAlertEndInEvacWithGaOffSilenced(void)
{
	/* 	Setup 		*/
	Test_GA_alertOnly_setup(silenceInAlertEnabled);
	/* Test state after alarm */
	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stAlert_gaOn_notSil_ledOff);

	/* 		Cycle part way through Alert delay, verify still in Alert  	*/
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);

	/* 		Simulate GA_OFF press, verify still in Alert state with GA ON*/
	BTN_btnEvent_testSet(eBtnGAoff, evt_yes);
	Test_verifyUint8( BTN_btnEvent_get(eBtnGAoff), evt_yes);

	/* 		Cycle through Alert delay to Evac --> GA_State = GA_E, GA_Output = ON, GA_Silenced = false 	*/
	Test_GA_alertCountDown(1, stAlert_gaOff_isSil_ledOn, stAlert_gaOff_isSil_ledOn, GA_ALERT_OFF, GA_ALERT_OFF);
	Test_GA_alertCountDown(1, stAlert_gaOff_isSil_ledOn, stEvac_gaOff_isSil_ledOn, GA_ALERT_OFF, GA_ALERT_ON);
//	Test_GA_alertCountDown(1, stAlert_gaOff_isSil_ledOn, stEvac_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
}
void Test_GA_alertOnly_silenceInAlertDisabled_gaOffDuring_hasNoEffectEndInEvacWithGaOn(enum SI_X siMe)
{
	Test_GA_templateSetup(GA_ALERT, stAlert_gaOn_notSil_ledOff);

	/* 		Cycle part way through Alert delay, verify still in Alert  	*/
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);

	/* 		Simulate GA_ON press, verify still in Alert state with GA ON*/
	BTN_btnEvent_testSet(eBtnGAoff, evt_yes);
	Test_verifyUint8( BTN_btnEvent_get(eBtnGAoff), evt_yes);

	/* 		Cycle through Alert delay to Evac --> GA_State = GA_E, GA_Output = ON, GA_Silenced = false 	*/
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
}
void Test_GA_evacInhibitSilenceOnly_countdown_endInEvac(void)
{
	Test_GA_templateSetup(GA_EVAC_INHIBIT_SILENCE, stEvacInhSil_gaOn_notSil_ledOff);
	Test_GA_countdownTemplate(stEvac_gaOn_notSil_ledOff, GA_TIMER_EVAC_MIN_10, 1);
}
void Test_GA_evacInhibitSilenceOnly_loseAlmDuring_hasNoEffectEndInEvac(void)
{
	Test_GA_templateSetup(GA_EVAC_INHIBIT_SILENCE, stEvacInhSil_gaOn_notSil_ledOff);
	Test_GA_loseAlmTemplate(stEvacInhSil_gaOn_notSil_ledOff, stEvacInhSil_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_TIMER_10>>2, GA_TIMER_10, 4);
}
void Test_GA_evacInhibitSilenceOnly_newAlmDuring_resetEvacInhibitTimerEndInEvac(void)
{
	Test_GA_templateSetup(GA_EVAC_INHIBIT_SILENCE, stEvacInhSil_gaOn_notSil_ledOff);
	Test_GA_newAlmTemplate(stEvacInhSil_gaOn_notSil_ledOff, stEvacInhSil_gaOn_notSil_ledOff);
	
	// Execute code
	val = GA_cycleTillState(GA_EVAC, GA_TIMER_EVAC_MIN_10);
	Test_verifyUint8( val, 2); // Tag to-do: I think this should be one??
	Test_GA_testResult(stEvac_gaOn_notSil_ledOff);
}
void Test_GA_evacInhibitSilenceOnly_gaOnDuring_hasNoEffectEndInEvac(void)
{
	Test_GA_templateSetup(GA_EVAC_INHIBIT_SILENCE, stEvacInhSil_gaOn_notSil_ledOff);
	Test_GA_gaOnTemplate(stEvacInhSil_gaOn_notSil_ledOff, stEvacInhSil_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_TIMER_10-2, 1);
}
void Test_GA_evacInhibitSilenceOnly_gaOffDuring_hasNoEffectEndInEvac(void)
{
	Test_GA_templateSetup(GA_EVAC_INHIBIT_SILENCE, stEvacInhSil_gaOn_notSil_ledOff);
	Test_GA_gaOffTemplate(stEvacInhSil_gaOn_notSil_ledOff, stEvacInhSil_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_TIMER_10-2, 1);
}
void Test_GA_evacInhibitSilenceOnly_enterSilenced_duringNotSilencedOutputOn_endInEvacGaOn(void)
{
	/* 	Setup 		*/
	Test_GA_evacInhibitSilenceAndAlert_setup(silenceInAlertEnabled);
	/* Test state after alarm */
	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stAlert_gaOn_notSil_ledOff);

	Test_GA_gaOffTemplate(stAlert_gaOn_notSil_ledOff, stAlert_gaOff_isSil_ledOn, stEvacInhSil_gaOn_notSil_ledOff, GA_TIMER_ALERT_12-2, 0);
	
	Test_GA_countdownTemplate(stEvac_gaOn_notSil_ledOff, GA_TIMER_EVAC_MIN_10, 1);
}
void Test_GA_evacAutoSilenceOnly_countdown_almPresetAtEnd_endInEvacSilencedOutputOff(void)
{
	Test_GA_templateSetup(GA_EVAC_AUTO_SILENCE, stEvacAutoSil_gaOn_notSil_ledOff);
	Test_GA_countdownTemplate(stEvac_gaOff_isSil_ledOn, GA_TIMER_EVAC_MIN_10, 1);
}
void Test_GA_evacAutoSilenceOnly_loseAlmDuring_noEffectTillTimerExpiresEndInNormalNotSilencedOutputOff(void)
{
	Test_GA_templateSetup(GA_EVAC_AUTO_SILENCE, stEvacAutoSil_gaOn_notSil_ledOff);
	Test_GA_loseAlmTemplate(stEvacAutoSil_gaOn_notSil_ledOff, stEvacAutoSil_gaOn_notSil_ledOff, stNorm_gaOff_notSil_ledOff, GA_TIMER_10>>2, GA_TIMER_10, 0);
}
void Test_GA_evacAutoSilenceOnly_newAlmDuring_resetEvacEndInEvacSilenced(void)
{
	Test_GA_templateSetup(GA_EVAC_AUTO_SILENCE, stEvacAutoSil_gaOn_notSil_ledOff);
	Test_GA_newAlmTemplate(stEvacAutoSil_gaOn_notSil_ledOff, stEvacAutoSil_gaOn_notSil_ledOff);
	
	// Execute code
	val = GA_cycleTillState(GA_EVAC, GA_TIMER_10);
	Test_verifyUint8( val, 2); // Tag to-do: I think this should be one??
	Test_GA_testResult(stEvac_gaOff_isSil_ledOn);
}
void Test_GA_evacAutoSilenceOnly_gaOnDuring_almPresetAtEnd_endInEvacIsSilencedOutputOff(void)
{
	Test_GA_templateSetup(GA_EVAC_AUTO_SILENCE, stEvacAutoSil_gaOn_notSil_ledOff);
	Test_GA_gaOnTemplate(stEvacAutoSil_gaOn_notSil_ledOff, stEvacAutoSil_gaOn_notSil_ledOff, stEvac_gaOff_isSil_ledOn, GA_TIMER_10, 3);
}
void Test_GA_evacAutoSilenceOnly_gaOnDuring_almClearAtEnd_endInNormalNotSilencedOutputOff(void)
{
	Test_GA_templateSetup(GA_EVAC_AUTO_SILENCE, stEvacAutoSil_gaOn_notSil_ledOff);
	Test_GA_gaOnTemplate(stEvacAutoSil_gaOn_notSil_ledOff, stEvacAutoSil_gaOn_notSil_ledOff, stEvacAutoSil_gaOn_notSil_ledOff, GA_TIMER_10>>2, 0);
	Test_GA_loseAlmTemplate(stEvacAutoSil_gaOn_notSil_ledOff, stEvacAutoSil_gaOn_notSil_ledOff, stNorm_gaOff_notSil_ledOff, GA_TIMER_10>>2, GA_TIMER_10, 0);
}
void Test_GA_evacAutoSilenceOnly_gaOffDuring_almPresent_isSilencedOutputOffDuring_endsInEvacSilencedOutputOffAfterCountdown(void)
{
	//void Test_GA_gaOnTemplate(enum Test_GA_id stateAfterAlarm, enum Test_GA_id stateAfterEvent, enum Test_GA_id stateFinal, WORD cycles)
	Test_GA_templateSetup(GA_EVAC_AUTO_SILENCE, stEvacAutoSil_gaOn_notSil_ledOff);
	Test_GA_gaOffTemplate(stEvacAutoSil_gaOn_notSil_ledOff, stEvacAutoSil_gaOff_isSil_ledOn, stEvac_gaOff_isSil_ledOn, GA_TIMER_10, 3);
}
void Test_GA_evacAutoSilenceOnly_gaOffDuring_almClear_isNotSilencedOutputOffDuring_endInNormalNotSilencedOutputOffAfterCountdown(void)
{
	Test_GA_templateSetup(GA_EVAC_AUTO_SILENCE, stEvacAutoSil_gaOn_notSil_ledOff);
	Test_GA_gaOffTemplate(stEvacAutoSil_gaOn_notSil_ledOff, stEvacAutoSil_gaOff_isSil_ledOn, stEvacAutoSil_gaOff_isSil_ledOn, GA_TIMER_10>>2, 0);
	Test_GA_loseAlmTemplate(stEvacAutoSil_gaOff_isSil_ledOn, stEvacAutoSil_gaOff_isSil_ledOn, stNorm_gaOff_notSil_ledOff, GA_TIMER_10>>2, GA_TIMER_10, 0);
}
//void Test_GA_evacAutoSilenceOnly_enterSilenced_duringSilencedOutputOff_endInEvac(void)
void Test_GA_evacAutoSilenceOnly_enterSilenced_duringNotSilencedOutputOn_endInEvacGaOff(void)
{
	/* 	Setup 		*/
	Test_GA_evacAutoSilenceAndAlert_setup(silenceInAlertEnabled);
	/* Test state after alarm */
	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stAlert_gaOn_notSil_ledOff);

	Test_GA_gaOffTemplate(stAlert_gaOn_notSil_ledOff, stAlert_gaOff_isSil_ledOn, stEvacAutoSil_gaOn_notSil_ledOff, GA_TIMER_ALERT_12-2, 0);
//	Test_GA_gaOffTemplate(stAlert_gaOn_notSil_ledOff, stAlert_gaOff_isSil_ledOn, stEvacAutoSil_gaOn_notSil_ledOff, GA_TIMER_ALERT_12-2, 0);

	Test_GA_countdownTemplate(stEvac_gaOff_isSil_ledOn, GA_TIMER_EVAC_MIN_10, 1);
}
void Test_GA_evacInhibitAndAutoSilence_autoLessThanInhibit_inhibitThenAutoSequentially(void)
{
	/* 	Setup 		*/
	Test_GA_evacInhibitAndAutoSilence_setup();
	/* Test state after alarm */
	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stEvacInhSil_gaOn_notSil_ledOff);
	Test_GA_countdownTemplate(stEvacAutoSil_gaOn_notSil_ledOff, GA_TIMER_EVAC_MIN_10, 0);
	Test_GA_countdownTemplate(stEvac_gaOff_isSil_ledOn, GA_TIMER_AUTO_SILENCE_2, 1);
}
//void Test_GA_evac_enterSilencedAlmPresent_duringIsSilencedOutputOff_endInEvac100cycles(void)
void Test_GA_evac_enterSilencedAlmPresent_duringIsSilencedOutputOff_endInEvacGaOff(void)
{
	/* 	Setup 		*/
	Test_GA_alertOnly_setup(silenceInAlertEnabled);
	/* Test state after alarm */
	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stAlert_gaOn_notSil_ledOff);

	Test_GA_gaOffTemplate(stAlert_gaOn_notSil_ledOff, stAlert_gaOff_isSil_ledOn, stEvac_gaOff_isSil_ledOn, GA_TIMER_ALERT_12-2, 1);
	Test_GA_countdownTemplate(stEvac_gaOff_isSil_ledOn, GA_TIMER_EVAC_MIN_10, 10);
}
void Test_GA_evac_enterNotSilencedAlmClear_duringIsNotSilencedOutputOn_endInEvacGaOn(void)
{
	// captured by Test_GA_alertOnly_loseAlmDuring_endInEvacGaOnNotSilenced()
}
void Test_GA_evac_loseAlmDuring_noEffectRemainInEvac(void)
{
	// captured by Test_GA_alertOnly_loseAlmDuring_endInEvacGaOnNotSilenced()
}
void Test_GA_evac_newAlmDuring_restartEvac(void)
{
	// captured by Test_GA_evacAutoSilenceOnly_newAlmDuring_resetEvacEndInEvacSilenced(), Test_GA_evacInhibitSilenceOnly_newAlmDuring_resetEvacInhibitTimerEndInEvac()
}
void Test_GA_evac_gaOnDuring_noEffectRemainInEvac(void)
{
	Test_GA_templateSetup(GA_NORMAL, stEvac_gaOn_notSil_ledOff);
	Test_GA_gaOnTemplate(stEvac_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_TIMER_10>>2, 2);
}
void Test_GA_evac_gaOffDuring_almPresent_endsInEvacSilencedOutputOff(void)
{
	Test_GA_templateSetup(GA_NORMAL, stEvac_gaOn_notSil_ledOff);
	Test_GA_gaOffTemplate(stEvac_gaOn_notSil_ledOff, stEvac_gaOff_isSil_ledOn, stEvac_gaOff_isSil_ledOn, GA_TIMER_ALERT_12-2, 10);
}
void Test_GA_evac_gaOffDuring_almClear_endInNormalNotSilencedOutputOff(void)
{
	Test_GA_templateSetup(GA_NORMAL, stEvac_gaOn_notSil_ledOff);
	Test_GA_loseAlmTemplate(stEvac_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, stEvac_gaOn_notSil_ledOff, GA_TIMER_10>>2, GA_TIMER_10, 10);
	Test_GA_gaOffTemplate(stEvac_gaOn_notSil_ledOff, stNorm_gaOff_notSil_ledOff, stNorm_gaOff_notSil_ledOff, GA_TIMER_ALERT_12-2, 0);
}

void Test_GA_evacAndInhibit_newAlmDuringEvac_restartEvac_endInEvacAfterInhibit(void)
{
	Test_GA_evacInhibitSilenceOnly_countdown_endInEvac();
	Test_GA_newAlmTemplate(stEvac_gaOn_notSil_ledOff, stEvacInhSil_gaOn_notSil_ledOff);
	Test_GA_countdownTemplate(stEvac_gaOn_notSil_ledOff, GA_TIMER_EVAC_MIN_10, 2);
}

void Test_GA_testAllTimers_countdownOnly(void)
{
	/*------------------------------------------------------*/
	/* 		Setup 										*/
	/*------------------------------------------------------*/
	Test_GA_allTimers_setup();

	/*------------------------------------------------------*/
	/* Notify GA of Alarm --> GA_State = GA_PreAlert, GA_Output = OFF, GA_Silenced = false*/
	/*------------------------------------------------------*/

	Test_GA_notifyGA_SIalm(SI_1, DO_NOT_SKIP_EVAC, stPreAlert_gaOff_notSil_ledOff);

	/*------------------------------------------------------*/
	/* Cycle through PreAlert delay to Alert */
	/*------------------------------------------------------*/

	// Execute code
	val = GA_cycleTillState(GA_EVAC, GA_TIMER_PRE_ALERT_10);
	Test_verifyUint8( val, 0);//1); // verify countdown for preAlert
	Test_GA_testResult(stAlert_gaOn_notSil_ledOff);

	/*------------------------------------------------------*/
	/* Cycle through Alert timer to Evac				*/
	/*------------------------------------------------------*/

	Test_GA_alertCountDown(2, stAlert_gaOff_notSil_ledOff, stAlert_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);
	Test_GA_alertCountDown(1, stAlert_gaOff_notSil_ledOff, stEvacInhSil_gaOn_notSil_ledOff, GA_ALERT_OFF, GA_ALERT_ON);

	/*------------------------------------------------------*/
	/* Cycle through evacInhSil delay to Evac --> GA_State = GA_EVAC, GA_Output = ON, GA_Silenced = false */
	/*------------------------------------------------------*/

	// Execute code
	val = GA_cycleTillState(GA_EVAC, GA_TIMER_EVAC_MIN_10);
	Test_verifyUint8( val, 0);//1); // verify countdown for preAlert
	Test_GA_testResult(stEvacAutoSil_gaOn_notSil_ledOff);

	/*------------------------------------------------------*/
	/* Cycle through evacAutoSil to Evac --> GA_State = GA_EVAC, GA_Output = OFF, GA_Silenced = false */
	/*------------------------------------------------------*/

	// Execute code
	val = GA_cycleTillState(GA_EVAC, GA_TIMER_AUTO_SILENCE_10);
	Test_verifyUint8( val, 1); // verify countdown for preAlert
	Test_GA_testResult(stEvac_gaOff_isSil_ledOn);
}


// Test_GA_<state>_<special_config>_<event>
// <state> : normal, preAlert, alert, evacInhibitSilence, evacAutoSilence, evac
// <special_config> : only affects alert -- silenceInAlert -- enabled or disabled
// <type> : countdown, event
// <event> : loseAlarm in state, new Alarm in state
// <result> :

void Test_GA_noTimersUseSI(enum SI_X siMe);
void Test_GA_noTimersBypassSI(enum SI_X siMe );

void Test_GA_preAlertOnly_countdown_PreAlertToEvac(enum SI_X siMe);
void Test_GA_preAlertOnly_loseAlmDuring_noEffectEndInEvac(enum SI_X siMe);
void Test_GA_preAlertOnly_newAlmDuring_straightToEvac(void);
void Test_GA_preAlertOnly_gaOnDuring_turnsOnGAendInEvac(void);
void Test_GA_preAlertOnly_gaOffDuring_hasNoEffectEndInEvac(void);

void Test_GA_alertOnly_countdown_silenceInAlertDisabled_endInEvacWithGaOn(enum SI_X siMe);
void Test_GA_alertOnly_invalidAlertOnOff_gaAlwaysOnDuring(void);
//void Test_GA_alertOnly_loseAlmDuring_endInNormalButStillCycling(void);
void Test_GA_alertOnly_newAlmDuring_straightToEvac(void);
void Test_GA_alertOnly_gaOnDuring_turnsOnGAendInEvacGaOn(void);
void Test_GA_alertOnly_silenceInAlertEnabled_gaOffDuring_gaTurnsOffDuringAlertEndInEvacWithGaOffSilenced(void);
void Test_GA_alertOnly_silenceInAlertDisabled_gaOffDuring_hasNoEffectEndInEvacWithGaOn(enum SI_X siMe);
//void Test_GA_alertOnly_enterSilenced_hasNormalCyclingBehavior(enum SI_X siMe); // This is not valid because you only enter Alert from PreAlert or Normal, and silenced = false on entry


void Test_GA_evacInhibitSilenceOnly_enterSilenced_duringNotSilencedOutputOn_endInEvacGaOn(void);
void Test_GA_evacInhibitSilenceOnly_countdown_endInEvac(void);
void Test_GA_evacInhibitSilenceOnly_loseAlmDuring_hasNoEffectEndInEvac(void);
void Test_GA_evacInhibitSilenceOnly_newAlmDuring_resetEvacInhibitTimerEndInEvac(void);
void Test_GA_evacInhibitSilenceOnly_gaOnDuring_hasNoEffectEndInEvac(void);
void Test_GA_evacInhibitSilenceOnly_gaOffDuring_hasNoEffectEndInEvac(void);

void Test_GA_evacAutoSilenceOnly_countdown_almPresetAtEnd_endInEvacSilencedOutputOff(void);
void Test_GA_evacAutoSilenceOnly_loseAlmDuring_noEffectTillTimerExpiresEndInNormalNotSilencedOutputOff(void);
void Test_GA_evacAutoSilenceOnly_newAlmDuring_resetEvacEndInEvacSilenced(void);
void Test_GA_evacAutoSilenceOnly_gaOnDuring_almPresetAtEnd_endInEvacIsSilencedOutputOff(void);
void Test_GA_evacAutoSilenceOnly_gaOnDuring_almClearAtEnd_endInNormalNotSilencedOutputOff(void);
void Test_GA_evacAutoSilenceOnly_gaOffDuring_almPresent_isSilencedOutputOffDuring_endsInEvacSilencedOutputOffAfterCountdown(void);
void Test_GA_evacAutoSilenceOnly_gaOffDuring_almClear_isNotSilencedOutputOffDuring_endInNormalNotSilencedOutputOffAfterCountdown(void);

void Test_GA_evacInhibitAndAutoSilence_autoLessThanInhibit_inhibitThenAutoSequentially(void);

void Test_GA_evac_enterSilencedAlmPresent_duringIsSilencedOutputOff_endInEvacGaOff(void);
//void Test_GA_evac_enterNotSilencedAlmClear_duringIsNotSilencedOutputOn_endInEvacGaOn(void);
//void Test_GA_evac_loseAlmDuring_noEffectRemainInEvac(void);
//void Test_GA_evac_newAlmDuring_restartEvac(void);
//void Test_GA_evac_gaOnDuring_noEffectRemainInEvac(void);
void Test_GA_evac_gaOffDuring_almPresent_endsInEvacSilencedOutputOff(void);
void Test_GA_evac_gaOffDuring_almClear_endInNormalNotSilencedOutputOff(void);

void Test_GA_evacAndInhibit_newAlmDuringEvac_restartEvac_endInEvacAfterInhibit(void);
void Test_GA_testAllTimers_countdownOnly(void);

void Test_GA(void)
{
	Test_GA_noTimersBypassSI(SI_2); // Implemented
	Test_GA_noTimersUseSI(SI_2);	// Implemented

	/*
	 * What is the intent of the preAlert stage?
	 * Why does the customer want it? What is it used for? Why not just use the SI timers??
	 *
	 */

	Test_GA_preAlertOnly_countdown_PreAlertToEvac(SI_1); // Implemented
	Test_GA_preAlertOnly_loseAlmDuring_noEffectEndInEvac(SI_1); // Implemented
	Test_GA_preAlertOnly_newAlmDuring_straightToEvac(); // Implemented
	Test_GA_preAlertOnly_gaOnDuring_turnsOnGAendInEvac(); // Implemented
	Test_GA_preAlertOnly_gaOffDuring_hasNoEffectEndInEvac(); // Implemented

	/*
	 * What is the intent of the Alert stage?
	 * Why does the customer want it? What is it used for?
	 * Why, if the alarm is lost during or at the end of the Alert stage, does the GA keep cycling on/off?
	 * 		Why would it just not turn on solid?
	 * 		It seems silly to allow the GA Output to be turned on during the Normal state...but not entirely because
	 * 		it can be turned on by pressing the GA_ON button. You can also GA_NORMAL from GA_EVAC if the alarms go
	 * 		away but GA_OFF hasn't been pressed.
	 * 		Perhaps GA_NORMAL should be partitioned into
	 * 			GA_NORMAL_OFF,
	 * 			GA_NORMAL_ALERT -- output cycles on and off per AlertOn and AlertOff, until the GA_OFF button is pressed, or until a new alarm is recieved.
	 * 				If almCount = 1 and evac=false, then go to alert_entry. If almCount > 1 or evac=true, then go to Evac_entry.
	 * 			GA_NORMAL_FORCED_ON --
	 * 			GA_NORMAL_WAIT_FOR_GA_OFF
	 * The only valid states to cycle the GA output on and off is Alert and Normal. If the GA is forced on by user pressing
	 * 		GA_ON, then the GA cannot cycle the output on and off - even if in the Alert stage.
	 * It is not valid, nor does it make sense, to be silenced in the NORMAL super state.
	 * In a sense, the GA is somewhat like a latching SI in that it requires a manual operator "reset." (The
	 * 		RESET button for SI and the GA_OFF button for the GA).
	 * There is not any specific equipment that is always hooked up to the GA. It can be what ever the customer wants.
	 * 		Often, it is some kind of annunciation device. To alert the operator of an alarm or fault condition, there are
	 * 		several options
	 * 			- make use of Fault Relay (for faults and Supervisory SI)
	 * 			- make use of Alarm Relay (for alarms on SI)
	 * 			- make use of GA
	 * 			- make use of SO
	 * The GA can always be silenced by pressing GA_OFF, except during the EVAC_INH_SIL state (the Evac Min timer).
	 * The GA can always be turned on by pressing GA_ON, in any state. This will keep the GA on until the operator
	 * 		presses GA_OFF or until the end of the EVAC_AUTO_SIL state.
	 * The only time the GA will turn off automatically, without pressing the GA_OFF button, is at the end of the
	 * 		EVAC_INH_SIL state.
	 * Entering EVAC states with GA silenced -- the GA output is always turned on when entering EVAC_INH_SIL and EVAC_AUTO_SIL, and off when entering EVAC
	 */

	Test_GA_alertOnly_countdown_silenceInAlertDisabled_endInEvacWithGaOn(SI_1); // Implemented
//	Test_GA_alertOnly_loseAlmDuring_endInNormalButStillCycling(); // discarded
	Test_GA_alertOnly_loseAlmDuring_endInEvacGaOnNotSilenced(); // Implemented
	Test_GA_alertOnly_newAlmDuring_straightToEvac(); // Implemented
	Test_GA_alertOnly_newAlmDuring_straightToEvac_viaSI();
	Test_GA_alertOnly_gaOnDuring_turnsOnGAendInEvacGaOn(); // Implemented
	Test_GA_alertOnly_silenceInAlertEnabled_gaOffDuring_gaTurnsOffDuringAlertEndInEvacWithGaOffSilenced(); // Implemented
	Test_GA_alertOnly_silenceInAlertDisabled_gaOffDuring_hasNoEffectEndInEvacWithGaOn(SI_1); // Implemented
//	Test_GA_alertOnly_enterSilenced_hasNormalCyclingBehavior(SI_1); // discarded - This is not valid because you only enter Alert from PreAlert or Normal, and silenced = false on entry
	Test_GA_alertOnly_invalidAlertOnOff_gaAlwaysOnDuring(); // Implemented -- if AlertOn = 0 or AlertOff = 0, this is invalid alertOnOff. Valid is AlertOn != 0 and AlertOff != 0
	
	Test_GA_evacInhibitSilenceOnly_countdown_endInEvac(); // Implemented
	Test_GA_evacInhibitSilenceOnly_loseAlmDuring_hasNoEffectEndInEvac(); // Implemented
	Test_GA_evacInhibitSilenceOnly_newAlmDuring_resetEvacInhibitTimerEndInEvac(); // Implemented
	Test_GA_evacInhibitSilenceOnly_gaOnDuring_hasNoEffectEndInEvac(); // Implemented
	Test_GA_evacInhibitSilenceOnly_gaOffDuring_hasNoEffectEndInEvac(); // Implemented
	Test_GA_evacInhibitSilenceOnly_enterSilenced_duringNotSilencedOutputOn_endInEvacGaOn(); // Implemented
	
	Test_GA_evacAutoSilenceOnly_countdown_almPresetAtEnd_endInEvacSilencedOutputOff(); // Implemented
	Test_GA_evacAutoSilenceOnly_loseAlmDuring_noEffectTillTimerExpiresEndInNormalNotSilencedOutputOff(); // Implemented-
	Test_GA_evacAutoSilenceOnly_newAlmDuring_resetEvacEndInEvacSilenced(); // Implemented
	Test_GA_evacAutoSilenceOnly_gaOnDuring_almPresetAtEnd_endInEvacIsSilencedOutputOff(); // Implemented
	Test_GA_evacAutoSilenceOnly_gaOnDuring_almClearAtEnd_endInNormalNotSilencedOutputOff(); // Implemented
	Test_GA_evacAutoSilenceOnly_gaOffDuring_almPresent_isSilencedOutputOffDuring_endsInEvacSilencedOutputOffAfterCountdown(); // Implemented
	Test_GA_evacAutoSilenceOnly_gaOffDuring_almClear_isNotSilencedOutputOffDuring_endInNormalNotSilencedOutputOffAfterCountdown(); // Implemented
	Test_GA_evacAutoSilenceOnly_enterSilenced_duringNotSilencedOutputOn_endInEvacGaOff(); // Implemented
	
	Test_GA_evacInhibitAndAutoSilence_autoLessThanInhibit_inhibitThenAutoSequentially(); // ---------------

//	Test_GA_evac_loseAlmDuring_noEffectRemainInEvac(); // discarded
//	Test_GA_evac_newAlmDuring_restartEvac(); // discarded
	Test_GA_evac_gaOnDuring_noEffectRemainInEvac(); // Implemented
	Test_GA_evac_gaOffDuring_almPresent_endsInEvacSilencedOutputOff(); // Implemented
	Test_GA_evac_gaOffDuring_almClear_endInNormalNotSilencedOutputOff(); // Implemented
	Test_GA_evac_enterSilencedAlmPresent_duringIsSilencedOutputOff_endInEvacGaOff(); // Implemented
//	Test_GA_evac_enterNotSilencedAlmClear_duringIsNotSilencedOutputOn_endInEvacGaOn(); // discarded
	
	Test_GA_evacAndInhibit_newAlmDuringEvac_restartEvac_endInEvacAfterInhibit(); // -Implemented

	Test_GA_testAllTimers_countdownOnly(); // Implemented
}
void Test_SI_setUpInputTypes(void)
{
	Test_GA_basicSetup(SI_1, SI_2);
//	void Test_SI_SH_loadInputFxnType(enum SI_X siMe, enum SI_functions fxn, enum SI_type type, enum SI_latch latch)
	Test_SI_SH_loadInputFxnType(SI_1, SI_Fxn_SUPERVISORY, 		SI_TYPE1, SI_latch_notLatched);
	Test_SI_SH_loadInputFxnType(SI_2, SI_Fxn_ALARM_NORMAL_GA, 	SI_TYPE2, SI_latch_isLatched);
	Test_SI_SH_loadInputFxnType(SI_3, SI_Fxn_SUPERVISORY, 		SI_TYPE3, SI_latch_notLatched);
	Test_SI_SH_loadInputFxnType(SI_4, SI_Fxn_ALARM_NORMAL_GA, 	SI_TYPE4, SI_latch_isLatched);
	Test_SI_SH_loadInputFxnType(SI_5, SI_Fxn_SUPERVISORY, 		SI_TYPE5, SI_latch_notLatched);
	Test_SI_SH_loadInputFxnType(SI_6, SI_Fxn_ALARM_NORMAL_GA, 	SI_TYPE6, SI_latch_isLatched);
	Test_SI_SH_loadInputFxnType(SI_7, SI_Fxn_SUPERVISORY, 		SI_TYPE7, SI_latch_notLatched);
	Test_SI_SH_loadInputFxnType(SI_8, SI_Fxn_SUPERVISORY, 		SI_TYPE8, SI_latch_isLatched);
}
void r26fSiInputTypes1to8(void)
{
	Test_SI_setUpInputTypes();
}
void r26gSiInputTypes2to9(void)
{
	Test_SI_setUpInputTypes();
	Test_SI_SH_loadInputFxnType(SI_1, SI_Fxn_SUPERVISORY, 		SI_TYPE9, SI_latch_notLatched);
}
void r26hSetUpFunctionTypes(void)
{
//	Test_GA_basicSetup(SI_1, SI_2);
//	Test_GA_preBasicSetup();

	/* Setup GA silence during Alert = disabled, all timers set to zero*/
	Test_GA_setupGA((BYTE)silenceInAlertEnabled, GA_TIMER_PRE_ALERT_0, GA_TIMER_ALERT_12, GA_TIMER_ALERT_ON_2, GA_TIMER_ALERT_OFF_2, GA_TIMER_EVAC_MIN_0, GA_TIMER_AUTO_SILENCE_0);
	SOSZ_test_GAfxnSO(SO_OBJ_1, SO_T_SO);

//	void Test_SI_SH_loadInputFxnType(enum SI_X siMe, enum SI_functions fxn, enum SI_type type, enum SI_latch latch)
	Test_SI_SH_loadInputFxnType(SI_1, SI_Fxn_INHIBIT_INPUT, 		SI_TYPE4, SI_latch_isLatched);
	Test_SI_SH_loadInputFxnType(SI_2, SI_Fxn_SILENT_STATUS_CHANGE, 	SI_TYPE4, SI_latch_isLatched);
	Test_SI_SH_loadInputFxnType(SI_3, SI_Fxn_STATUS_CHANGE, 		SI_TYPE4, SI_latch_isLatched);
	Test_SI_SH_loadInputFxnType(SI_4, SI_Fxn_SUPERVISORY, 			SI_TYPE4, SI_latch_isLatched);
	Test_SI_SH_loadInputFxnType(SI_5, SI_Fxn_ALARM_NO_GA, 			SI_TYPE4, SI_latch_isLatched);
	Test_SI_SH_loadInputFxnType(SI_6, SI_Fxn_ALARM_NORMAL_GA, 		SI_TYPE4, SI_latch_isLatched);
	Test_SI_SH_loadInputFxnType(SI_7, SI_Fxn_ALARM_SKIP_TO_EVAC, 	SI_TYPE4, SI_latch_isLatched);
}
void Test_SI_inputTypes(void)
{
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(SI_1);
	Test_SI_setUpInputTypes();
	/*
	    {4050, 4095, SI_ADC_FAULT},		// undefined
		{1000, 4049, SI_ADC_ALARM},		// shorted
		{585, 999, SI_ADC_FAULT},		// undefined
		{250, 584, SI_ADC_NORMAL},		// open
		{0, 249, SI_ADC_FAULT}			// eol missing
	 */
	enum SI_X siMe;
	/* Test SI 1*/
	siMe = SI_1;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 200);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_ALARM);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 400);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 600);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 2000);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_NORMAL);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 4070);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	/* Test SI 2*/
	siMe = SI_2;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 200);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 400);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_ALARM);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 600);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 2000);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_NORMAL);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 4070);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	/* Test SI 3*/
	siMe = SI_3;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 200);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_NORMAL);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 400);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 600);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 2000);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_ALARM);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 4070);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	/* Test SI 4*/
	siMe = SI_4;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 200);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 400);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_NORMAL);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 600);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 2000);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_ALARM);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 4070);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	/* Test SI 5*/
	siMe = SI_5;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 200);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_NORMAL);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 400);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 600);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 2000);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_ALARM);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 4070);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	/* Test SI 6*/
	siMe = SI_6;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 200);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 400);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_NORMAL);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 600);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 2000);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_ALARM);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 4070);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	/* Test SI 7*/
	siMe = SI_7;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 200);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 400);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_NORMAL);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 600);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 2000);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_ALARM);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 4070);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	/* Test SI 8*/
	siMe = SI_8;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 200);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 400);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_NORMAL);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 600);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 2000);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_ALARM);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 4070);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	/* Test SI 8, with input type 9*/
	Test_SI_SH_loadInputFxnType(SI_8, SI_Fxn_SUPERVISORY, 		SI_TYPE9, SI_latch_isLatched);
	siMe = SI_8;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 200);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_ALARM);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 400);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_NORMAL);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 600);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 2000);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);

	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_norm, 4070);
	Test_verifyUint8(SI_getAdcState(siMe), SI_ADC_FAULT);
}
void Test_SI_StatusFxn_doesNotDriveGlobLedAndRelay(void)
{
	enum SI_X siMe;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(SI_1);

	Test_GA_basicSetup(SI_1, SI_2);
//	void Test_SI_SH_loadInputFxnType(enum SI_X siMe, enum SI_functions fxn, enum SI_type type, enum SI_latch latch)
	Test_SI_SH_loadInputFxnType(SI_1, SI_Fxn_STATUS_CHANGE, SI_TYPE4, SI_latch_notLatched);
	SI_init();

	siMe = SI_1;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_test, 200);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForAck, siMe);
}
void Test_SI_SilentFxn_doesNotDriveBuzzerOrGlobalLedAndRelay(void)
{
	enum SI_X siMe;
	struct SI_threadInfo_t * pSI_threadInfo = SI_rtnThreadInfo(SI_1);

	Test_GA_basicSetup(SI_1, SI_2);
//	void Test_SI_SH_loadInputFxnType(enum SI_X siMe, enum SI_functions fxn, enum SI_type type, enum SI_latch latch)
	Test_SI_SH_loadInputFxnType(SI_1, SI_Fxn_SILENT_STATUS_CHANGE, SI_TYPE4, SI_latch_notLatched);
	SI_init();

	siMe = SI_1;
	Test_SI_threadParams(siMe, SI_ADC_ALARM, SI_STATE_alarmWaitForAck, 1, SI_runMode_test, SI_runMode_test, 200);
	Test_SI_verifyOutputs(SI_STATE_NS_alarmWaitForAck, siMe);
}
void FWS_setInput(enum FWS_Sector sector, enum FWS_Input input, enum FWS_Status status);//enum SI_ADC_STATE value);
enum FWS_Status FWS_getOutputStatus(enum FWS_Sector sector, enum FWS_Output output);
enum FWS_OutputCfgMask FWS_getOutputCfg(enum FWS_Sector, enum FWS_Output);
enum FWS_Status FWS_getSectorStatus(enum FWS_Sector);
enum FWS_State FWS_getSectorState(enum FWS_Sector);
enum FWS_Status FWS_getInputStatus(enum FWS_Sector, enum FWS_Input);
enum FWS_Status FWS_getInputPhyStatus(enum FWS_Sector, enum FWS_Input);
enum SI_ADC_STATE FWS_getInputPhyAdcStatus(enum FWS_Sector sector, enum FWS_Input input);
enum FWS_InputCfgMask FWS_getInputPhyCfg(enum FWS_Sector, enum FWS_Input);

void Test_FWS_zeroAllFwsConfig(void)
{
	struct FWS * pFWScfg = (struct FWS *)&pConfigMemRAM->fws[0];
	memset((void*)pFWScfg, 0, sizeof(struct FWS)*8);
}
void Test_FWS_cfgSetCfgByte(enum FWS_Sector sector, BYTE cfg)
{
	struct FWS * pFWScfg = (struct FWS *)&pConfigMemRAM->fws[sector];
//	(BYTE) *(&pFWScfg->Start + 1) = cfg;
	BYTE * p = (BYTE *)(&pFWScfg->Start + 1);
	*p = cfg;
//	(BYTE) pFWScfg->XZone = cfg;
}
void Test_FWS_cfgSetCfg(enum FWS_Sector sector, BYTE XZone, BYTE EnableDet1PreReleaseDelay, BYTE EnableDet2PreReleaseDelay, BYTE EnableMCPPreReleaseDelay, BYTE LockoffCancel, BYTE ReleaseAbort, BYTE Det1OneShot, BYTE MCPOneShot)
{
	struct FWS * pFWScfg = (struct FWS *)&pConfigMemRAM->fws[sector];
	pFWScfg->cfg.XZone = XZone;
	pFWScfg->cfg.EnableDet1PreReleaseDelay = EnableDet1PreReleaseDelay;
	pFWScfg->cfg.EnableDet2PreReleaseDelay = EnableDet2PreReleaseDelay;
	pFWScfg->cfg.EnableMCPPreReleaseDelay = EnableMCPPreReleaseDelay;
	pFWScfg->cfg.LockoffCancel = LockoffCancel;
	pFWScfg->cfg.ReleaseAbort = ReleaseAbort;
	pFWScfg->cfg.Det1OneShot = Det1OneShot;
	pFWScfg->cfg.MCPOneShot = MCPOneShot;
}
void Test_FWS_cfgSetCfgMask(enum FWS_Sector sector, BYTE XZone, BYTE EnableDet1PreReleaseDelay, BYTE EnableDet2PreReleaseDelay, BYTE EnableMCPPreReleaseDelay, BYTE LockoffCancel, BYTE ReleaseAbort, BYTE Det1OneShot, BYTE MCPOneShot)
{
	struct FWS * pFWScfg = (struct FWS *)&pConfigMemRAM->fws[sector];
	BYTE mask = XZone + EnableDet1PreReleaseDelay + EnableDet2PreReleaseDelay + EnableMCPPreReleaseDelay + LockoffCancel + ReleaseAbort + Det1OneShot + MCPOneShot;
//	(BYTE) *(&pFWScfg->Start[1]) = mask;
	BYTE * p = (BYTE *)(&pFWScfg->Start + 1);
	*p = mask;
//	(BYTE) pFWScfg->XZone = mask;
}
void Test_FWS_cfgSetOneMask(enum FWS_Sector sector, enum FWS_releaseOptions opt, BYTE value)
{
	struct FWS * pFWScfg = (struct FWS *)&pConfigMemRAM->fws[sector];
	switch (opt)
	{
		case FWS_CFG_CROSS_ZONE_1_AND_2:
			pFWScfg->cfg.XZone = value;
			break;
		case FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1:
			pFWScfg->cfg.EnableDet1PreReleaseDelay = value;
			break;
		case FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2:
			pFWScfg->cfg.EnableDet2PreReleaseDelay = value;
			break;
		case FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT:
			pFWScfg->cfg.EnableMCPPreReleaseDelay = value;
			break;
		case FWS_CFG_INPUT_CANCEL_1_LOCKOFF_0:
			pFWScfg->cfg.LockoffCancel = value;
			break;
		case FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0:
			pFWScfg->cfg.ReleaseAbort= value;
			break;
		case FWS_CFG_ONESHOT_DETECTION_ZONE_1:
			pFWScfg->cfg.Det1OneShot = value;
			break;
		case FWS_CFG_ONESHOT_MCP:
			pFWScfg->cfg.MCPOneShot = value;
			break;
		default:
			break;
	}
}
void Test_FWS_cfgSetInputs(enum FWS_Sector sector, enum FWS_InputCfgMask det1, enum FWS_InputCfgMask det2, enum FWS_InputCfgMask mcp, enum FWS_InputCfgMask lockoutCancel, enum FWS_InputCfgMask abortExtraRel)
{
	struct FWS * pFWScfg = (struct FWS *)&pConfigMemRAM->fws[sector];
	pFWScfg->input.Det1Input = det1;
	pFWScfg->input.Det2Input = det2;
	pFWScfg->input.MCPInput = mcp;
	pFWScfg->input.LockoffInput = lockoutCancel;
	pFWScfg->input.AbortInput = abortExtraRel;
}
void Test_FWS_cfgSetTimers(enum FWS_Sector sector, BYTE preRel, BYTE abort, BYTE start, BYTE firstDump, BYTE dumpOn, BYTE dumpOff, BYTE pause, BYTE reset, BYTE c1, BYTE c2, BYTE interlock)
{
	struct FWS * pFWScfg = (struct FWS *)&pConfigMemRAM->fws[sector];
	struct FWS_Ext02 	*pFWS_Ext02 = (struct FWS_Ext02 *)&pConfigMemRAM->fwsEx02[sector];
	pFWScfg->timers.PreReleaseTimer = preRel;
	pFWScfg->timers.AbortTimer = abort;
	pFWScfg->timers.StartupTimer = start;
	pFWScfg->timers.DumpOnTimer = dumpOn;
	pFWScfg->timers.DumpOffTimer = dumpOff;
	pFWScfg->timers.PauseTimer = pause;
	pFWScfg->timers.ResetTimer = reset;
	pFWScfg->timers.C1Counter = c1;
	pFWScfg->timers.C2Counter = c2;
	pFWScfg->timers.Interlock = interlock;
	pFWS_Ext02->FirstDumpOnTimer = firstDump;
}
void Test_FWS_cfgSetOneTimer(enum FWS_Sector sector, enum FWS_Timers timer, BYTE value)
{
	struct FWS * pFWScfg = (struct FWS *)&pConfigMemRAM->fws[sector];
	struct FWS_Ext02 	*pFWS_Ext02 = (struct FWS_Ext02 *)&pConfigMemRAM->fwsEx02[sector];
	BYTE *pTimer;
	switch (timer)
	{
		case FWS_TMR_PreReleaseTimer:
		case FWS_TMR_Abort:
		case FWS_TMR_Startup:
		case FWS_TMR_DumpOn:
		case FWS_TMR_DumpOff:
		case FWS_TMR_Pause:
		case FWS_TMR_Reset:
		case FWS_TMR_C1Counter:
		case FWS_TMR_C2Counter:
		case FWS_TMR_Interlock:
			pTimer = (BYTE*)&pFWScfg->timers;
			pTimer[timer] = value;
			break;
		case FWS_TMR_FirstDumpOn:
			pFWS_Ext02->FirstDumpOnTimer = value;
			break;
	}
}
void Test_FWS_cfgResetTimers(enum FWS_Sector sector, BYTE time)
{
	struct FWS *pFWScfg = (struct FWS *)&pConfigMemRAM->fws[sector];
	WORD *pTimer = (WORD*)&pFWScfg->timers;
	struct FWS_Ext02 	*pFWS_Ext02 = (struct FWS_Ext02 *)&pConfigMemRAM->fwsEx02[sector];
	memset(pTimer, time, sizeof(struct FWS_cfgTimers));
	pFWS_Ext02->FirstDumpOnTimer = time;
}
#define FWS_TIMER_0 0
#define FWS_TIMER_30 30
#define FWS_C1_MAX 255 //8
#define FWS_C1_MIN 1
#define FWS_C2_MAX 255 //8
#define FWS_C2_MIN 0 //1
#define FWS_INTERLOCK_MIN 1
#define FWS_INTERLOCK_MAX 8

void Test_FWS_cfgSetOutputs(enum FWS_Sector sector, BYTE hpSol, BYTE lpSol, BYTE preRelAnnun, BYTE relAnnun, BYTE shutdown, BYTE reset, BYTE relMode)
{
	struct FWS 			*pFWScfg    = (struct FWS *)&pConfigMemRAM->fws[sector];
	struct FWS_Ext02 	*pFWS_Ext02 = (struct FWS_Ext02 *)&pConfigMemRAM->fwsEx02[sector];
	pFWScfg->output.HPSolenoidOutput = hpSol;
	pFWScfg->output.LPSolenoidOutput = lpSol;
	pFWScfg->output.PreReleaseAnnOutput = preRelAnnun;
	pFWScfg->output.ReleaseAnnOutput = relAnnun;
	pFWScfg->output.ShutdownOutput = shutdown;
	pFWScfg->output.ResetOutput = reset;
	pFWS_Ext02->ReleaseModeOutput = relMode;

}
void Test_FWS_loadConfig(void)
{
	BYTE cfg = FWS_CFG_NOT_SET
//			+ FWS_CFG_CROSS_ZONE_1_AND_2
			+ FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1
			+ FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2
			+ FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT__OFF
			+ FWS_CFG_INPUT_CANCEL_1_LOCKOFF_0
			+ FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0
			+ FWS_CFG_ONESHOT_DETECTION_ZONE_1
			+ FWS_CFG_ONESHOT_MCP
			;
	Test_FWS_cfgSetCfgByte(FWS_SECTOR_1, cfg);
//	Test_FWS_cfgSetCfg(enum FWS_Sector sector, BYTE XZone, BYTE EnableDet1PreReleaseDelay, BYTE EnableDet2PreReleaseDelay, BYTE EnableMCPPreReleaseDelay, BYTE LockoffCancel, BYTE ReleaseAbort, BYTE Det1OneShot, BYTE MCPOneShot)
	Test_FWS_cfgSetCfgMask(FWS_SECTOR_2, FWS_CFG_CROSS_ZONE_1_AND_2__OFF, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1,
			FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2, FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT__OFF, FWS_CFG_INPUT_CANCEL_1_LOCKOFF_0,
			FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0, FWS_CFG_ONESHOT_DETECTION_ZONE_1, FWS_CFG_ONESHOT_MCP);
	Test_FWS_cfgSetCfg(FWS_SECTOR_3, FWS_INACTIVE, FWS_ACTIVE, FWS_ACTIVE, FWS_INACTIVE, FWS_ACTIVE, FWS_ACTIVE, FWS_ACTIVE, FWS_ACTIVE);

//	Test_FWS_cfgSetTimers(enum FWS_Sector sector, BYTE preRel, BYTE abort, BYTE start, BYTE dumpOn, BYTE dumpOff, BYTE pause, BYTE reset, BYTE c1, BYTE c2)
	Test_FWS_cfgSetTimers(FWS_SECTOR_1, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_C1_MIN, FWS_C2_MIN, FWS_INTERLOCK_MAX);
	Test_FWS_cfgSetTimers(FWS_SECTOR_2, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_C1_MAX, FWS_C2_MAX, FWS_INTERLOCK_MAX);

//	Test_FWS_cfgSetOutputs(enum FWS_Sector sector, BYTE hpSol, BYTE lpSol, BYTE preRelAnnun, BYTE relAnnun, BYTE shutdown, BYTE reset)
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_SO_3, FWS_OUT_CFG_SO_4, FWS_OUT_CFG_RL_1, FWS_OUT_CFG_RL_2, FWS_OUT_CFG_RL_3);

//	Test_FWS_cfgSetInputs(enum FWS_Sector sector, enum FWS_InputCfgMask det1, enum FWS_InputCfgMask det2, enum FWS_InputCfgMask mcp, enum FWS_InputCfgMask lockoutCancel, enum FWS_InputCfgMask abortExtraRel)
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_SI_1, FWS_INP_CFG_SZ_1, FWS_INP_CFG_SI_2, FWS_INP_CFG_SI_3, FWS_INP_CFG_SI_4);
	Test_FWS_cfgSetInputs(FWS_SECTOR_3, FWS_INP_CFG_SI_1, FWS_INP_CFG_SZ_1, FWS_INP_CFG_SI_2, FWS_INP_CFG_SI_3, FWS_INP_CFG_SI_4);
}
void Test_FWS_resetCfg_allSectors(void)
{
	enum FWS_Sector i;
	for (i=FWS_SECTOR_BEGIN; i<FWS_SECTOR_COUNT; i++)
	{
		Test_FWS_cfgSetCfg(i, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE);
	}
}
void Test_FWS_resetTimers_allSectors(void)
{
	enum FWS_Sector i;
	for (i=FWS_SECTOR_BEGIN; i<FWS_SECTOR_COUNT; i++)
	{
		Test_FWS_cfgResetTimers(i, 0);
	}
}
void Test_FWS_resetAllSectors(void)
{
	enum FWS_Sector i;
	for (i=FWS_SECTOR_BEGIN; i<FWS_SECTOR_COUNT; i++)
	{
		Test_FWS_cfgSetInputs(i, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE);
		Test_FWS_cfgSetOutputs(i, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE);
		Test_FWS_cfgResetTimers(i, 0);
		Test_FWS_cfgSetCfg(i, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE);
	}
}
void Test_FWS_loadCfgSimple(void)
{
//	Test_FWS_cfgSetCfg(enum FWS_Sector sector, BYTE XZone, BYTE EnableDet1PreReleaseDelay, BYTE EnableDet2PreReleaseDelay, BYTE EnableMCPPreReleaseDelay, BYTE LockoffCancel, BYTE ReleaseAbort, BYTE Det1OneShot, BYTE MCPOneShot)
	Test_FWS_resetAllSectors();
	Test_FWS_cfgSetCfgMask(FWS_SECTOR_1,
			FWS_CFG_CROSS_ZONE_1_AND_2__OFF,
			FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1__OFF,
			FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2__OFF,
			FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT__OFF,
			FWS_CFG_INPUT_CANCEL_1_LOCKOFF_0,
			FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0__OFF,
			FWS_CFG_ONESHOT_DETECTION_ZONE_1__OFF,
			FWS_CFG_ONESHOT_MCP__OFF);
	Test_FWS_cfgSetCfg(FWS_SECTOR_2, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE);
	Test_FWS_cfgSetCfg(FWS_SECTOR_3, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE);
	Test_FWS_cfgSetCfg(FWS_SECTOR_4, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE);
	Test_FWS_cfgSetCfg(FWS_SECTOR_5, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE);
	Test_FWS_cfgSetCfg(FWS_SECTOR_6, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE);
	Test_FWS_cfgSetCfg(FWS_SECTOR_7, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE);
	Test_FWS_cfgSetCfg(FWS_SECTOR_8, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE);
//	Test_FWS_cfgSetCfg(FWS_SECTOR_3, FWS_ACTIVE, FWS_ACTIVE, FWS_ACTIVE, FWS_ACTIVE, FWS_ACTIVE, FWS_ACTIVE, FWS_ACTIVE, FWS_ACTIVE);

//	Test_FWS_cfgSetTimers(enum FWS_Sector sector, BYTE preRel, BYTE abort, BYTE start, BYTE dumpOn, BYTE dumpOff, BYTE pause, BYTE reset, BYTE c1, BYTE c2)
//	Test_FWS_cfgSetTimers(FWS_SECTOR_1, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_C1_MIN, FWS_C2_MIN, FWS_INTERLOCK_MAX);
	Test_FWS_cfgResetTimers(FWS_SECTOR_1, 0);
//	Test_FWS_cfgSetTimers(FWS_SECTOR_2, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_TIMER_30, FWS_C1_MAX, FWS_C2_MAX, FWS_INTERLOCK_MAX);

//	Test_FWS_cfgSetOutputs(enum FWS_Sector sector, BYTE hpSol, BYTE lpSol, BYTE preRelAnnun, BYTE relAnnun, BYTE shutdown, BYTE reset)
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_SO_3, FWS_OUT_CFG_SO_4, FWS_OUT_CFG_RL_1, FWS_OUT_CFG_RL_2, FWS_OUT_CFG_RL_3);

//	Test_FWS_cfgSetInputs(enum FWS_Sector sector, enum FWS_InputCfgMask det1, enum FWS_InputCfgMask det2, enum FWS_InputCfgMask mcp, enum FWS_InputCfgMask lockoutCancel, enum FWS_InputCfgMask abortExtraRel)
//	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_SI_1, FWS_INP_CFG_SZ_1, FWS_INP_CFG_SI_2, FWS_INP_CFG_SI_3, FWS_INP_CFG_SI_4);
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_SI_1, FWS_INP_CFG_SI_2, FWS_INP_CFG_SI_3, FWS_INP_CFG_SI_4, FWS_INP_CFG_SI_5);

	SOSZ_clearSOSZ_SILoAlm(SI_1_to_8);
}
void Test_FWS_verifyCfgSimple(void)
{
	Test_verifyUint8(FWS_getOutputCfg(FWS_SECTOR_1, FWS_OUT_HP_SOL), FWS_OUT_CFG_SO_1);
	Test_verifyUint8(FWS_getOutputCfgType(FWS_SECTOR_1, FWS_OUT_HP_SOL), SO_T_SO);
	Test_verifyUint8(FWS_getOutputCfgNum(FWS_SECTOR_1, FWS_OUT_HP_SOL), SO_OBJ_1);

	enum FWS_OutputCfgMask 	cfg 	= FWS_OUT_CFG_NONE;
	enum SO_objectType 		objType = SO_T_NULL;
	enum SO_objectNumber 	num 	= SO_OBJ_NULL;
	FWS_getOutputCfgAll(FWS_SECTOR_1, FWS_OUT_HP_SOL, &cfg, &objType, &num);
	Test_verifyUint8(cfg, FWS_OUT_CFG_SO_1);
	Test_verifyUint8(objType, SO_T_SO);
	Test_verifyUint8(num, SO_OBJ_1);

	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_1), FWS_INACTIVE);
	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_2), FWS_INACTIVE);

	Test_verifyUint8(FWS_getInputPhyCfg(FWS_SECTOR_1, FWS_INP_DET_ZONE_1), FWS_INP_CFG_SI_1);
	Test_verifyUint8(FWS_getInputPhyCfgType(FWS_SECTOR_1, FWS_INP_DET_ZONE_1), FWS_T_SI);
	Test_verifyUint8(FWS_getInputPhyCfgNum(FWS_SECTOR_1, FWS_INP_DET_ZONE_1), SI_1);
}
void Test_FWS_verifyInitial(void)
{
	Test_verifyUint8(FWS_getSectorState(FWS_SECTOR_1), FWS_STATE_STANDBY);
	Test_verifyUint8(FWS_getOutputStatus(FWS_SECTOR_1, FWS_OUT_HP_SOL), FWS_INACTIVE);
	Test_verifyUint8(FWS_getInputStatus(FWS_SECTOR_1, FWS_INP_DET_ZONE_1), SI_ADC_NORMAL);
}
struct Test_FWS_outputTable_t {
	enum FWS_State state;
	enum FWS_Status hpSol;
	enum FWS_Status lpSol;
	enum FWS_Status preRelAnn;
	enum FWS_Status relAnn;
	enum FWS_Status shutdown;
	enum FWS_Status reset;
	enum FWS_Status relMode;
};

const struct Test_FWS_outputTable_t Test_FWS_outputTable [] = {
//			state							hpSol		lpSol		preRelAnn		relAnnun	shutdown		reset		relMode
		{FWS_STATE_NULL, 				FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE},
		{FWS_STATE_STANDBY, 			FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE},

		{FWS_STATE_PRE_RELEASE, 		FWS_INACTIVE, FWS_INACTIVE, FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE  , FWS_INACTIVE, FWS_INACTIVE},

		{FWS_STATE_STARTUP, 			FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE  , FWS_ACTIVE  , FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE},

		{FWS_STATE_FIRST_DUMP_ON, 		FWS_ACTIVE  , FWS_ACTIVE,   FWS_ACTIVE  , FWS_ACTIVE  , FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE},
		{FWS_STATE_DUMP_ON, 			FWS_ACTIVE,   FWS_ACTIVE,   FWS_ACTIVE  , FWS_ACTIVE  , FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE},
		{FWS_STATE_DUMP_OFF, 			FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE  , FWS_ACTIVE  , FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE},

		{FWS_STATE_PAUSE, 				FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE  , FWS_ACTIVE  , FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE},
		{FWS_STATE_RESET_ON, 			FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE  , FWS_ACTIVE  , FWS_ACTIVE  , FWS_ACTIVE,   FWS_ACTIVE},
		{FWS_STATE_RESET_OFF, 			FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE  , FWS_ACTIVE  , FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE},

		{FWS_STATE_ABORT, 				FWS_INACTIVE, FWS_INACTIVE, FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE  , FWS_INACTIVE, FWS_INACTIVE},
		{FWS_STATE_ABORT_WAIT_RELEASED, FWS_INACTIVE, FWS_INACTIVE, FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE  , FWS_INACTIVE, FWS_INACTIVE},
		{FWS_STATE_ABORT_TIMER, 		FWS_INACTIVE, FWS_INACTIVE, FWS_ACTIVE  , FWS_INACTIVE, FWS_ACTIVE  , FWS_INACTIVE, FWS_INACTIVE},

		{FWS_STATE_NO_WATER, 			FWS_ACTIVE,   FWS_ACTIVE,   FWS_ACTIVE  , FWS_ACTIVE,   FWS_ACTIVE,   FWS_INACTIVE, FWS_INACTIVE},
		{FWS_STATE_WAIT_FOR_NEXT_ALARM, FWS_ACTIVE,   FWS_ACTIVE,   FWS_ACTIVE,   FWS_ACTIVE,   FWS_ACTIVE,   FWS_INACTIVE, FWS_INACTIVE},

		{FWS_STATE_CANCEL, 				FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE},
		{FWS_STATE_LOCKOFF, 			FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE, FWS_INACTIVE}
};
void Test_FWS_verifyOutputs(enum FWS_Sector sector, enum FWS_State state)
{
	int failCount = 0;
	failCount += Test_verifyUint8(Test_FWS_outputTable[state].state, state);
	failCount += Test_verifyUint8(FWS_getSectorState(sector), state);
	failCount += Test_verifyUint8(FWS_getOutputStatus(sector, FWS_OUT_HP_SOL), Test_FWS_outputTable[state].hpSol);
	failCount += Test_verifyUint8(FWS_getOutputStatus(sector, FWS_OUT_LP_SOL), Test_FWS_outputTable[state].lpSol);
	failCount += Test_verifyUint8(FWS_getOutputStatus(sector, FWS_OUT_PRE_REL_ANNUN), Test_FWS_outputTable[state].preRelAnn);
	failCount += Test_verifyUint8(FWS_getOutputStatus(sector, FWS_OUT_REL_ANNUN), Test_FWS_outputTable[state].relAnn);
	failCount += Test_verifyUint8(FWS_getOutputStatus(sector, FWS_OUT_SHUTDOWN), Test_FWS_outputTable[state].shutdown);
	failCount += Test_verifyUint8(FWS_getOutputStatus(sector, FWS_OUT_RESET), Test_FWS_outputTable[state].reset);
	failCount += Test_verifyUint8(FWS_getOutputStatus(sector, FWS_OUT_RELEASE_MODE), Test_FWS_outputTable[state].relMode);
	if (failCount != 0)
	{
		__no_operation();
	}
}
void Test_FWS_setupCfgSimpleRefresh(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_verifyCfgSimple();

	FWS_init();
	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_1), FWS_ACTIVE);
	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_2), FWS_INACTIVE);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
}
void Test_FWS_standbytoNoWater_cfgSimple(void)
{
	Test_FWS_setupCfgSimpleRefresh();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
	SOSZ_notifySOSZ_SILoAlm(1<<SI_1);
	FWS_getInputPhyStatus(FWS_SECTOR_1, FWS_INP_DET_ZONE_1);

	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_forceInputNoSI()
{
	Test_FWS_setupCfgSimpleRefresh();
	FWS_setInput(FWS_SECTOR_1, FWS_INP_DET_ZONE_1, FWS_ACTIVE);//SI_ADC_ALARM);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_setAlarmFixedCfg(enum FWS_inputObjectType type, enum FWS_Input input, enum FWS_Status val)
{
//	void SOSZ_notifySOSZ_SZtrigger(WORD index);
//	void SOSZ_notifySOSZ_SZtrigger8(BYTE index);
//	void SOSZ_clearSOSZ_SZtrigger8(BYTE index);

	enum SI_X num;
	switch (input)
	{
		case FWS_INP_DET_ZONE_1:
			num = SI_1;
			break;
		case FWS_INP_DET_ZONE_2:
			num = SI_2;
			break;
		case FWS_INP_MCP:
			num = SI_3;
			break;
		case FWS_INP_LOCKOFF:
		case FWS_INP_CANCEL:
			num = SI_4;
			break;
		case FWS_INP_ABORT:
		case FWS_INP_EXTRA_RELEASE:
			num = SI_5;
			break;
	}
	switch (type)
	{
		case FWS_T_SI:
			if (val == FWS_ACTIVE)
				SOSZ_notifySOSZ_SILoAlm(1<<num);
			else
				SOSZ_clearSOSZ_SILoAlm(1<<num);
			break;
		case FWS_T_SZ:
			if (val == FWS_ACTIVE)
//				SOSZ_notifySOSZ_SZtrigger8_test(1<<num);
				SOSZ_notifySOSZ_SZtrigger_test(1<<num);
			else
				SOSZ_clearSOSZ_SZtrigger_test(1<<num);
			break;
	}
}
void Test_FWS_setAlarmFixedCfgHigh(enum FWS_inputObjectType type, enum FWS_Input input, enum FWS_Status val)
{
//	void SOSZ_notifySOSZ_SZtrigger(WORD index);
//	void SOSZ_notifySOSZ_SZtrigger8(BYTE index);
//	void SOSZ_clearSOSZ_SZtrigger8(BYTE index);

	enum SI_X num;
	switch (input)
	{
		case FWS_INP_DET_ZONE_1:
			num = SI_1;
			break;
		case FWS_INP_DET_ZONE_2:
			num = SI_2;
			break;
		case FWS_INP_MCP:
			num = SI_3;
			break;
		case FWS_INP_LOCKOFF:
		case FWS_INP_CANCEL:
			num = SI_4;
			break;
		case FWS_INP_ABORT:
		case FWS_INP_EXTRA_RELEASE:
			num = SI_4;
			break;
	}
	switch (type)
	{
		case FWS_T_SI:
			if (val == FWS_ACTIVE)
				SOSZ_notifySOSZ_SIHiAlm(1<<num);
			else
				SOSZ_clearSOSZ_SIHiAlm(1<<num);
			break;
		case FWS_T_SZ:
			num += SI_9;
			if (val == FWS_ACTIVE)
				SOSZ_notifySOSZ_SZtrigger_test(1<<num);
			else
				SOSZ_notifySOSZ_SZtrigger_test(1<<num);
			break;
	}
}
void Test_FWS_stateTransitionTemplate(enum FWS_Sector sector, enum FWS_Timers tmr, BYTE tmVal, enum FWS_State end, BYTE c1, BYTE c2)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneTimer(sector, tmr, tmVal);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C1Counter, c1);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C2Counter, c2);
//	Test_FWS_cfgSetTimers(FWS_SECTOR_1, FWS_TIMER_30, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_TIMER_0, FWS_C1_MIN, FWS_C2_MIN, FWS_INTERLOCK_MAX);

	FWS_init();
	Test_FWS_verifyOutputs(sector, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(sector, end);
}
void Test_FWS_standbyToPreRelease_simplePreReleaseOnly(void)
{
	Test_FWS_stateTransitionTemplate(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30, FWS_STATE_PRE_RELEASE, 0, 0);
}
void Test_FWS_standbyToPreRelease_abortSetFirst_simplePreReleaseOnly(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Abort, 40);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0, FWS_INACTIVE);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C1Counter, 0);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C2Counter, 0);

	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_ABORT);

}
void Test_FWS_standbyToPreRelease_mcpPreRelease(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Abort, 40);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT, FWS_ACTIVE);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C1Counter, 0);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C2Counter, 0);

	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_MCP, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
}
void Test_FWS_standbyToStartup_simpleStartupOnly(void)
{
	Test_FWS_stateTransitionTemplate(FWS_SECTOR_1, FWS_TMR_Startup, 30, FWS_STATE_STARTUP, 0, 0);
}
void Test_FWS_standbyToDumpOn_simpleDumpOnOnly(BYTE c1, BYTE c2)
{
	Test_FWS_stateTransitionTemplate(FWS_SECTOR_1, FWS_TMR_DumpOn, 30, FWS_STATE_DUMP_ON, c1, c2);

/*	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_DumpOn, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	SOSZ_notifySOSZ_SILoAlm(1<<SI_1);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STARTUP);*/
}
void Test_FWS_standbyToFirstDumpOn_simpleDumpOnAndFirstDumpOnOnly(BYTE c1, BYTE c2)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_DumpOn, 30);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_FirstDumpOn, 30);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C1Counter, c1);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C2Counter, c2);

	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_FIRST_DUMP_ON);
}
void Test_FWS_lockoff_standbyToLockoff(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_CANCEL_1_LOCKOFF_0, FWS_lockoff);

	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_LOCKOFF, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_LOCKOFF);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_LOCKOFF);
}
void Test_FWS_lockoff_removeLockoffAlmPresent_toNoWater(void)
{
	Test_FWS_lockoff_standbyToLockoff();

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_LOCKOFF, FWS_INACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_lockoff_removeLockoffAlmClear_toStandby(void)
{
	Test_FWS_lockoff_standbyToLockoff();

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_INACTIVE);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_LOCKOFF, FWS_INACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
}
void Test_FWS_cancel_standbyToCancel(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_CANCEL_1_LOCKOFF_0, FWS_cancel);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_CANCEL, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_CANCEL);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_CANCEL);
}
void Test_FWS_cancel_removeCancel_resetAlmPresent_stayInCancel(void)
{
	Test_FWS_cancel_standbyToCancel();

	/* Clear Cancel Input */
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_CANCEL, FWS_INACTIVE);
	/* Simulate press of RESET Button*/
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_CANCEL);
}
void Test_FWS_cancel_removeCancel_resetAlmClear_toStandby(void)
{
	Test_FWS_cancel_standbyToCancel();

	/* Clear Cancel Input */
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_CANCEL, FWS_INACTIVE);
	/* Clear Alarm on Input */
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_INACTIVE);
	/* Simulate press of RESET Button*/
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
}
void Test_FWS_cancel_standbytoNoWaterToCancel(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_CANCEL_1_LOCKOFF_0, FWS_cancel);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_CANCEL, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_CANCEL);
}
void Test_FWS_crosszone_standbytoNoWater(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_CROSS_ZONE_1_AND_2, FWS_ACTIVE);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_2, FWS_ACTIVE);
	FWS_thread();
	FWS_getInputStatus(FWS_SECTOR_1, FWS_INP_DET_ZONE_2);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_crosszoneAndPreRelease_standbyToPreRelease(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_CROSS_ZONE_1_AND_2, FWS_ACTIVE);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_2, FWS_ACTIVE);
	FWS_thread();
	FWS_getInputStatus(FWS_SECTOR_1, FWS_INP_DET_ZONE_2);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

}
void Test_FWS_crosszone_setDet2ForceTriggerWithMCP_standbytoNoWater(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_CROSS_ZONE_1_AND_2, FWS_ACTIVE);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_2, FWS_ACTIVE);
	FWS_thread();
	FWS_getInputStatus(FWS_SECTOR_1, FWS_INP_DET_ZONE_2);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_MCP, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_preRelease_countdown_toNoWater(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	int i;
	for (i=0; i<29; i++)
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
	}
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);

}
void Test_FWS_preRelease_verifyPreReleaseEnabledHelper(enum FWS_Sector sector, enum FWS_releaseOptions opt, enum FWS_Status stat, enum FWS_Input inp, enum FWS_State state)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, opt, stat);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, inp, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, state);
}
void Test_FWS_preRelease_verifyPreReleaseEnabledForZone1_notForZone2orMCP_standbyToPreRelease(void)
{
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE, FWS_INP_DET_ZONE_2,   FWS_STATE_NO_WATER);
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE, FWS_INP_MCP, 	      FWS_STATE_NO_WATER);
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_INACTIVE, FWS_INP_DET_ZONE_1, FWS_STATE_NO_WATER);
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE, FWS_INP_DET_ZONE_1,   FWS_STATE_PRE_RELEASE);
}
void Test_FWS_preRelease_verifyPreReleaseEnabledForZone2_notForZone1orMCP_standbyToPreRelease(void)
{
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2, FWS_ACTIVE, FWS_INP_DET_ZONE_1,   FWS_STATE_NO_WATER);
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2, FWS_ACTIVE, FWS_INP_MCP, 	      FWS_STATE_NO_WATER);
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2, FWS_INACTIVE, FWS_INP_DET_ZONE_2, FWS_STATE_NO_WATER);
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2, FWS_ACTIVE, FWS_INP_DET_ZONE_2,   FWS_STATE_PRE_RELEASE);
}
void Test_FWS_preRelease_verifyPreReleaseEnabledForMCP_notForZone1orZone2_standbyToPreRelease(void)
{
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT, FWS_ACTIVE, FWS_INP_DET_ZONE_1, FWS_STATE_NO_WATER);
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT, FWS_ACTIVE, FWS_INP_DET_ZONE_2, FWS_STATE_NO_WATER);
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT, FWS_INACTIVE, FWS_INP_MCP, 		FWS_STATE_NO_WATER);
	Test_FWS_preRelease_verifyPreReleaseEnabledHelper(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT, FWS_ACTIVE, FWS_INP_MCP,   		FWS_STATE_PRE_RELEASE);
}
void Test_FWS_preRelease_verifyPreReleaseEnabledForZone1CrossZone_standbyToPreRelease(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_CROSS_ZONE_1_AND_2, FWS_ACTIVE);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_2, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
}
void Test_FWS_preRelease_countdown_toDumpOn(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_DumpOn, 30);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	int i;
	for (i=0; i<29; i++)
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
	}
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_DUMP_ON);
}
void Test_FWS_preRelease_abortInput_toAbort(void)
{
// Abort not configured, extraRelease is configured
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0, FWS_extraRelease);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	int i;
	for (i=0; i<10; i++)
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
	}
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_ACTIVE);
	for (i=0; i<19; i++)
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
	}
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);

// Abort is configured, not extraRelease
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0, FWS_abort);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	for (i=0; i<10; i++)
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
	}
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_ABORT);
}
void Test_FWS_preRelease_mcpAlmDuring_exitPreReleaseImmediately_checkTimerstoNoWater(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_MCP, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_preRelease_inputsRtnNormalDuringPreRelease_completePreRelCountdownThentoNoWater_____Q__(void)
{
	/* ----------------------------------------------------------------------------------------------------------- */
	// This may actually return to normal at the end of the preRelease, or it could transition right away too...
	/* ----------------------------------------------------------------------------------------------------------- */
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
//	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_DumpOn, 30);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_INACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	int i;
	for (i=0; i<28; i++)
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
	}
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_abort_abortHeldTillEnd_15of30preReleaseAddedToAbortOf30forCountdownof45_toAbortWaitForReleased(enum FWS_Status inputStatus)
{
//	Test_FWS_preRelease_abortInput_toAbort();

// Abort is configured, not extraRelease
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0, FWS_abort);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Abort, 30);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

	int i;
	for (i=0; i<14; i++)
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
	}
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_ACTIVE);
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, inputStatus);
	for (i=0; i<45; i++)
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_ABORT);
	}
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_ABORT_WAIT_RELEASED);
}
void Test_FWS_abort_abortHeldTillEndAlmPresent_toAbortWaitForReleased(void)
{
	Test_FWS_abort_abortHeldTillEnd_15of30preReleaseAddedToAbortOf30forCountdownof45_toAbortWaitForReleased(FWS_ACTIVE);
}
void Test_FWS_abort_abortHeldTillEndAlmClear_toAbortWaitForReleased(void)
{
	Test_FWS_abort_abortHeldTillEnd_15of30preReleaseAddedToAbortOf30forCountdownof45_toAbortWaitForReleased(FWS_INACTIVE);
}
void Test_FWS_abort_abortReleasedDuringCountDown_toAbortWaitTimer(void)
{
	//	Test_FWS_preRelease_abortInput_toAbort();

	// Abort is configured, not extraRelease
		Test_FWS_loadCfgSimple();
		Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
		Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0, FWS_abort);
		Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
		Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Abort, 30);
		FWS_init();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

		Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

		int i;
		for (i=0; i<14; i++)
		{
			FWS_thread();
			Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
		}
		Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_ACTIVE);
		Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
		for (i=0; i<15; i++)
		{
			FWS_thread();
			Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_ABORT);
		}
		Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_INACTIVE);
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_ABORT_TIMER);
}
void Test_FWS_abort_mcpDuring_checkTimersNoOtherTimerCfg_toNoWater(void)
{
	//	Test_FWS_preRelease_abortInput_toAbort();

	// Abort is configured, not extraRelease
		Test_FWS_loadCfgSimple();
		Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1, FWS_ACTIVE);
		Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0, FWS_abort);
		Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
		Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Abort, 30);
		FWS_init();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

		Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);

		int i;
		for (i=0; i<14; i++)
		{
			FWS_thread();
			Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_PRE_RELEASE);
		}
		Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_ACTIVE);
		Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
		for (i=0; i<15; i++)
		{
			FWS_thread();
			Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_ABORT);
		}
		Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_MCP, FWS_ACTIVE);
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_abortWaitForReleased_abortReleasedAlmPresent_checkTimersNoOtherTimerCfg_toNoWater(void)
{
	Test_FWS_abort_abortHeldTillEndAlmPresent_toAbortWaitForReleased();
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_INACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_abortWaitForReleased_abortReleasedAlmPresent_checkTimersStartupCfg_toStartup(void)
{
	Test_FWS_abort_abortHeldTillEndAlmPresent_toAbortWaitForReleased();
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Startup, 30);  // this is somewhat cheating, because this should be set before FWS_init() is called
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_INACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STARTUP);
}
void Test_FWS_abortWaitForReleased_abortReleasedAlmPresent_checkTimersDumpOnCfg_toDumpOn(void)
{
	Test_FWS_abort_abortHeldTillEndAlmPresent_toAbortWaitForReleased();
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_DumpOn, 30);  // this is somewhat cheating, because this should be set before FWS_init() is called
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_INACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_DUMP_ON);
}
void Test_FWS_abortWaitForReleased_abortReleasedAlmPresent_checkTimersFirstDumpOnCfg_toFirstDumpOn(void)
{
	Test_FWS_abort_abortHeldTillEndAlmPresent_toAbortWaitForReleased();
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_DumpOn, 30);  // this is somewhat cheating, because this should be set before FWS_init() is called
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_FirstDumpOn, 30);
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_INACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_FIRST_DUMP_ON);
}
void Test_FWS_abortWaitForReleased_abortReleasedAlmClear_toStandby(void)
{
	Test_FWS_abort_abortHeldTillEndAlmClear_toAbortWaitForReleased();
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_ABORT, FWS_INACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
}
void Test_FWS_abortWaitForReleased_mcpDuring_checkTimersNoOtherTimerCfg_toNoWater(void)
{
	Test_FWS_abort_abortHeldTillEndAlmPresent_toAbortWaitForReleased();
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_MCP, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_abortTimer_countdownHelper(enum FWS_Status inputDuringCountdown, enum FWS_State finalState)
{
	Test_FWS_abort_abortReleasedDuringCountDown_toAbortWaitTimer();
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, inputDuringCountdown);
	int i;
	for (i=0; i<29; i++) // 29 instead of 30 b/c there was a call to FWS_thread at end of Test_FWS_abort_abortReleasedDuringCountDown_toAbortWaitTimer
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_ABORT_TIMER);
	}
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, finalState);
}
void Test_FWS_abortTimer_countdownAlmPresent_checkTimersNoOtherTimerCfg_toNoWater(void)
{
	Test_FWS_abortTimer_countdownHelper(FWS_ACTIVE, FWS_STATE_NO_WATER);
}
void Test_FWS_abortTimer_countdownAlmClear_checkTimersNoOtherTimerCfg_toStandby(void)
{
	Test_FWS_abortTimer_countdownHelper(FWS_INACTIVE, FWS_STATE_STANDBY);
}
void Test_FWS_abortTimer_mcpDuring_checkTimersNoOtherTimerCfg_toNoWater(void)
{
	Test_FWS_abort_abortReleasedDuringCountDown_toAbortWaitTimer();
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_MCP, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_countdownHelper(enum FWS_Status inputDuringCountdown, enum FWS_State duringState, enum FWS_State finalState)
{
	switch (duringState)
	{
		case FWS_STATE_STARTUP:
			Test_FWS_standbyToStartup_simpleStartupOnly();
			break;
		case FWS_STATE_DUMP_ON:
			Test_FWS_standbyToDumpOn_simpleDumpOnOnly(0, 0);
			break;
	}
	switch (finalState)
	{
		case FWS_STATE_NO_WATER:
		case FWS_STATE_WAIT_FOR_NEXT_ALARM:
			break;
		case FWS_STATE_FIRST_DUMP_ON:
			Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_FirstDumpOn, 30);
	//		break;   // no break because we want to set DumpOn as well
		case FWS_STATE_DUMP_ON:
		case FWS_STATE_DUMP_OFF:
			Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_DumpOn, 30);  // this is somewhat cheating, because this should be set before FWS_init() is called
			Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C1Counter, 0);
			break;
	}
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, inputDuringCountdown);
	int i;
	for (i=0; i<29; i++) // 29 instead of 30 b/c there was a call to FWS_thread at end of Test_FWS_abort_abortReleasedDuringCountDown_toAbortWaitTimer
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, duringState);
	}
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, finalState);
}
void Test_FWS_startup_countdownAlmPresent_checkTimersNoOtherTimerCfg_toNoWater(void)
{
	Test_FWS_countdownHelper(FWS_ACTIVE, FWS_STATE_STARTUP, FWS_STATE_NO_WATER);
}
void Test_FWS_startup_countdownAlmClear_checkTimersNoOtherTimerCfg_toNoWater(void)
{
	Test_FWS_countdownHelper(FWS_INACTIVE, FWS_STATE_STARTUP, FWS_STATE_NO_WATER);
}
void Test_FWS_startup_countdownAlmPresent_checkTimersDumpOnCfg_toDumpOn(void)
{
	Test_FWS_countdownHelper(FWS_ACTIVE, FWS_STATE_STARTUP, FWS_STATE_DUMP_ON);
}
void Test_FWS_startup_countdownAlmPresent_checkTimersFirstDumpOnCfg_toFirstDumpOn(void)
{
	Test_FWS_countdownHelper(FWS_ACTIVE, FWS_STATE_STARTUP, FWS_STATE_FIRST_DUMP_ON);
}
void Test_FWS_dumpCycle_timerCfg(BYTE dumpOn, BYTE dumpOff, BYTE pause, BYTE c1, BYTE c2, BYTE firstDumpOn)
{
	if (firstDumpOn)
	{
		Test_FWS_standbyToFirstDumpOn_simpleDumpOnAndFirstDumpOnOnly(c1, c2);
	}
	else
	{
		Test_FWS_standbyToDumpOn_simpleDumpOnOnly(c1, c2);
	}
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_DumpOn, dumpOn);  // this is somewhat cheating, because this should be set before FWS_init() is called
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_DumpOff, dumpOff);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Pause, pause);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C1Counter, c1);
//	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C2Counter, c2);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_FirstDumpOn, firstDumpOn);
}
void Test_FWS_endCycle_timerCfg(BYTE c2, BYTE pause, BYTE reset)
{
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Pause, pause);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C2Counter, c2);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Reset, reset);
}
void Test_FWS_countdown(BYTE loops, enum FWS_State duringState, enum FWS_State finalState)
{
	int i;
	for (i=0; i<loops; i++) // 29 instead of 30 b/c there was a call to FWS_thread at end of Test_FWS_abort_abortReleasedDuringCountDown_toAbortWaitTimer
	{
		FWS_thread();
		Test_FWS_verifyOutputs(FWS_SECTOR_1, duringState);
	}
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, finalState);
}
void Test_FWS_dumpOn_countdownAlmPresent_toDumpOff(void)
{
//	Test_FWS_countdownHelper(FWS_ACTIVE, FWS_STATE_DUMP_ON, FWS_STATE_DUMP_OFF);
	Test_FWS_dumpCycle_timerCfg(30, 30, 30, 2, 2, 0);
	Test_FWS_countdown(29, FWS_STATE_DUMP_ON, FWS_STATE_DUMP_OFF);

//	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_ONESHOT_DETECTION_ZONE_1, FWS_ACTIVE);
//	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_ONESHOT_MCP, FWS_ACTIVE);
}
void Test_FWS_dumpOn_countdownAlmPresent_toNoWater_dumpOffAndPauseZero(void)
{
	Test_FWS_dumpCycle_timerCfg(30, 0, 0, 0, 0, 0);
	Test_FWS_countdown(29, FWS_STATE_DUMP_ON, FWS_STATE_NO_WATER);
}
void Test_FWS_dumpOnCycle_C1setZeroIsOne_countdownAlmPresent_toPause(BYTE c2)
{
	Test_FWS_dumpCycle_timerCfg(30, 30, 30, 2, c2, 0);
	Test_FWS_countdown(29, FWS_STATE_DUMP_ON, FWS_STATE_DUMP_OFF);
	Test_FWS_countdown(29, FWS_STATE_DUMP_OFF, FWS_STATE_DUMP_ON);
	Test_FWS_countdown(29, FWS_STATE_DUMP_ON, FWS_STATE_PAUSE);
}
void Test_FWS_dumpOnCycle_C1setMaxIsMax_countdownAlmPresent_toPause(void)
{
	Test_FWS_dumpCycle_timerCfg(2, 2, 30, FWS_C1_MAX, 0, 0);
	int i;
	for (i=0; i<(FWS_C1_MAX-1); i++)
	{
		Test_FWS_countdown(1, FWS_STATE_DUMP_ON, FWS_STATE_DUMP_OFF);  // 000 to 029
		Test_FWS_countdown(1, FWS_STATE_DUMP_OFF, FWS_STATE_DUMP_ON);  // 030 to 059
	}
	Test_FWS_countdown(1, FWS_STATE_DUMP_ON, FWS_STATE_PAUSE);
}
void Test_FWS_dumpOnCycle_C1overMaxIsMax_countdownAlmPresent_toPause(void)
{
	// not possible because we are limited to byte type
}
void Test_FWS_dumpOn_oneShotDet1_det1LastSet_toPause(void)
{
	Test_FWS_dumpCycle_timerCfg(2, 2, 30, FWS_C1_MAX, 0, 0);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_ONESHOT_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_countdown(1, FWS_STATE_DUMP_ON, FWS_STATE_PAUSE);
}
void Test_FWS_dumpOn_oneShotDet1_det1NotLastSet_toDumpOff(void)
{
	Test_FWS_dumpCycle_timerCfg(2, 2, 30, FWS_C1_MAX, 0, 0);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_ONESHOT_DETECTION_ZONE_1, FWS_ACTIVE);
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_MCP, FWS_ACTIVE);
	Test_FWS_countdown(1, FWS_STATE_DUMP_ON, FWS_STATE_DUMP_OFF);
}
void Test_FWS_dumpOn_oneShotMCP_mcpNotLastSet_toDumpOff(void)
{
	Test_FWS_dumpCycle_timerCfg(2, 2, 30, FWS_C1_MAX, 0, 0);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_ONESHOT_MCP, FWS_ACTIVE);
	Test_FWS_countdown(1, FWS_STATE_DUMP_ON, FWS_STATE_DUMP_OFF);
}
void Test_FWS_dumpOn_oneShotMCP_mcpLastSet_toPause(void)
{
	Test_FWS_dumpCycle_timerCfg(2, 2, 30, FWS_C1_MAX, 0, 0);
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_ONESHOT_MCP, FWS_ACTIVE);
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_MCP, FWS_ACTIVE);
	Test_FWS_countdown(1, FWS_STATE_DUMP_ON, FWS_STATE_PAUSE);
}
void Test_FWS_dumpOnCycle_C1setOneIsOne_countdownAlmPresent_toDumpOffToDumpOnNoWater(void)
{
	Test_FWS_dumpCycle_timerCfg(30, 30, 0, 2, 0, 0);
	Test_FWS_countdown(29, FWS_STATE_DUMP_ON, FWS_STATE_DUMP_OFF);
	Test_FWS_countdown(29, FWS_STATE_DUMP_OFF, FWS_STATE_DUMP_ON);
	Test_FWS_countdown(29, FWS_STATE_DUMP_ON, FWS_STATE_NO_WATER);
}
void Test_FWS_firstDumpOnCycle_countdownAlmPresent_toDumpOffToDumpOnToNoWater(void)
{
	Test_FWS_dumpCycle_timerCfg(30, 30, 0, 2, 0, 60); // (BYTE dumpOn, BYTE dumpOff, BYTE pause, BYTE c1, BYTE c2, BYTE firstDumpOn)
	Test_FWS_countdown(59, FWS_STATE_FIRST_DUMP_ON, FWS_STATE_DUMP_OFF);
	Test_FWS_countdown(29, FWS_STATE_DUMP_OFF, FWS_STATE_DUMP_ON);
	Test_FWS_countdown(29, FWS_STATE_DUMP_ON, FWS_STATE_NO_WATER);
}
void Test_FWS_pause_countdown_toResetOn(BYTE c2)
{
	Test_FWS_dumpOnCycle_C1setZeroIsOne_countdownAlmPresent_toPause(c2);
	Test_FWS_endCycle_timerCfg(0, 10, 10); // (BYTE c2, BYTE pause, BYTE reset)
	Test_FWS_countdown(9, FWS_STATE_PAUSE, FWS_STATE_RESET_ON);
}
void Test_FWS_pause_countdown_toNoWater_viaEndOfCycle_skipReset(void)
{   // no reset -- c2=0
	Test_FWS_dumpOnCycle_C1setZeroIsOne_countdownAlmPresent_toPause(0);
	Test_FWS_endCycle_timerCfg(0, 10, 0); // (BYTE c2, BYTE pause, BYTE reset)
	Test_FWS_countdown(9, FWS_STATE_PAUSE, FWS_STATE_NO_WATER);
}
void Test_FWS_pause_countdown_toDumpOn_viaEndOfCycle_skipReset(void)
{ 	// c2 > 0, alarms still present
	Test_FWS_dumpOnCycle_C1setZeroIsOne_countdownAlmPresent_toPause(2);
	Test_FWS_endCycle_timerCfg(2, 10, 0); // (BYTE c2, BYTE pause, BYTE reset)
	Test_FWS_countdown(9, FWS_STATE_PAUSE, FWS_STATE_DUMP_ON);
}
void Test_FWS_pause_countdown_toWaitForNext_viaEndOfCycle_skipReset(void)
{	// c2 > 0, alarm is clear at end of cycle
	Test_FWS_dumpOnCycle_C1setZeroIsOne_countdownAlmPresent_toPause(2);
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_INACTIVE);
	Test_FWS_endCycle_timerCfg(2, 10, 0);
	Test_FWS_countdown(9, FWS_STATE_PAUSE, FWS_STATE_WAIT_FOR_NEXT_ALARM);
}
void Test_FWS_resetOn_countdown_toResetOff(BYTE c2)
{
	Test_FWS_pause_countdown_toResetOn(c2);
	Test_FWS_countdown(9, FWS_STATE_RESET_ON, FWS_STATE_RESET_OFF);
}
void Test_FWS_resetOff_countdown_toNoWater_viaEndOfCycle(void)
{
	Test_FWS_resetOn_countdown_toResetOff(0);
	Test_FWS_countdown(9, FWS_STATE_RESET_OFF, FWS_STATE_NO_WATER);
}
void Test_FWS_resetOff_countdown_toDumpOn_viaEndOfCycle(void)
{
	Test_FWS_resetOn_countdown_toResetOff(2);
	Test_FWS_countdown(9, FWS_STATE_RESET_OFF, FWS_STATE_DUMP_ON);
}
void Test_FWS_resetOff_countdown_toWaitForNext_viaEndOfCycle(void)
{
	Test_FWS_resetOn_countdown_toResetOff(2);
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_INACTIVE);
	Test_FWS_countdown(9, FWS_STATE_RESET_OFF, FWS_STATE_WAIT_FOR_NEXT_ALARM);
}
void Test_FWS_waitForNextAlarm_newAlarm_toStartupSkipPreRelease_viaCheckTimer(void)
{
	Test_FWS_pause_countdown_toWaitForNext_viaEndOfCycle_skipReset();
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_PreReleaseTimer, 30);
	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_Startup, 30);
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_DUMP_ON);
}
void Test_FWS_waitForNextAlarm_resetPressedAlmClear_toStandby(void)
{
	Test_FWS_pause_countdown_toWaitForNext_viaEndOfCycle_skipReset();
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	FWS_thread();
	Test_verifyUint8( BTN_btnEvent_get(eBtnReset), evt_no);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
}
void Test_FWS_noWater_newAlarm_stayInNoWater(void)
{
	Test_FWS_pause_countdown_toNoWater_viaEndOfCycle_skipReset();
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_2, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_noWater_resetPressedAlmPresent_stayInNoWater(void)
{
	Test_FWS_pause_countdown_toNoWater_viaEndOfCycle_skipReset();
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_2, FWS_ACTIVE);
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	FWS_thread();
	Test_verifyUint8( BTN_btnEvent_get(eBtnReset), evt_no);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_noWater_resetPressedAlmClear_toStandby(void)
{
	Test_FWS_pause_countdown_toNoWater_viaEndOfCycle_skipReset();
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_INACTIVE);
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	FWS_thread();
	Test_verifyUint8( BTN_btnEvent_get(eBtnReset), evt_no);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
}
void Test_FWS_extraReleaseTest(void)
{
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOneMask(FWS_SECTOR_1, FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0, FWS_extraRelease);
//	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C2Counter, c2);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_EXTRA_RELEASE, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_input_szLow(void)
{
	Test_FWS_resetAllSectors();
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_SZ_1, FWS_INP_CFG_SI_2, FWS_INP_CFG_SI_3, FWS_INP_CFG_SI_4, FWS_INP_CFG_SI_5);
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_SO_3, FWS_OUT_CFG_SO_4, FWS_OUT_CFG_RL_1, FWS_OUT_CFG_RL_2, FWS_OUT_CFG_RL_3);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SZ, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_input_siHigh(void)
{
	Test_FWS_resetAllSectors();
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_SI_9, FWS_INP_CFG_SI_2, FWS_INP_CFG_SI_3, FWS_INP_CFG_SI_4, FWS_INP_CFG_SI_5);
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_SO_3, FWS_OUT_CFG_SO_4, FWS_OUT_CFG_RL_1, FWS_OUT_CFG_RL_2, FWS_OUT_CFG_RL_3);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfgHigh(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_input_szHigh(void)
{
	Test_FWS_resetAllSectors();
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_SZ_9, FWS_INP_CFG_SI_2, FWS_INP_CFG_SI_3, FWS_INP_CFG_SI_4, FWS_INP_CFG_SI_5);
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_SO_3, FWS_OUT_CFG_SO_4, FWS_OUT_CFG_RL_1, FWS_OUT_CFG_RL_2, FWS_OUT_CFG_RL_3);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfgHigh(FWS_T_SZ, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_det2(void)
{
	Test_FWS_loadCfgSimple();
//	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C2Counter, c2);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_2, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_mcp(void)
{
	Test_FWS_loadCfgSimple();
//	Test_FWS_cfgSetOneTimer(FWS_SECTOR_1, FWS_TMR_C2Counter, c2);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_MCP, FWS_ACTIVE);
	FWS_thread();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS_configuration(void)
{
	/*
	 * Inputs -- one must be set of Det_1, Det_2, or MCP; don't care for lockoffCancel, abortExtra
	 * Outputs -- Both Hp and Lp must be set; don't care about others
	 * Timers -- no timers are required to be set
	 * Cfg -- no special configurations are required to be set
	 */
	Test_FWS_resetCfg_allSectors();
	Test_FWS_resetTimers_allSectors();
	/* No Inputs or Outputs Set - Sector Inactive*/
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE);
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE);
	FWS_init();
	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_1), FWS_INACTIVE);

	/* Minimal Inputs Set, No Outputs Set - Sector Inactive*/
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_SI_1, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE);
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE);
	FWS_init();
	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_1), FWS_INACTIVE);

	/* Minimal Outputs Set, No Inputs Set - Sector Inactive*/
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE);
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE);
	FWS_init();
	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_1), FWS_INACTIVE);

	/* Minimal Inputs and Outputs Set - Sector Active*/
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_SI_1, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE);
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE);
	FWS_init();
	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_1), FWS_ACTIVE);

	/* Minimal Inputs and Outputs Set - Sector Active*/
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_NONE, FWS_INP_CFG_SI_1, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE);
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE);
	FWS_init();
	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_1), FWS_ACTIVE);

	/* Minimal Inputs and Outputs Set - Sector Active*/
	Test_FWS_cfgSetInputs(FWS_SECTOR_1, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE, FWS_INP_CFG_SI_1, FWS_INP_CFG_NONE, FWS_INP_CFG_NONE);
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE, FWS_OUT_CFG_NONE);
	FWS_init();
	Test_verifyUint8(FWS_getSectorStatus(FWS_SECTOR_1), FWS_ACTIVE);
}
void Test_FWS_multSectors_setup(BYTE interlock)
{
	Test_FWS_resetCfg_allSectors();
	Test_FWS_resetTimers_allSectors();
	enum FWS_Sector i;
	for (i=FWS_SECTOR_BEGIN; i<FWS_SECTOR_COUNT; i++)
	{
		Test_FWS_cfgSetOneTimer(i, FWS_TMR_Interlock, interlock);
		Test_FWS_cfgSetOutputs(i, FWS_OUT_CFG_SO_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_SO_3, FWS_OUT_CFG_SO_4, FWS_OUT_CFG_RL_1, FWS_OUT_CFG_RL_2, FWS_OUT_CFG_RL_3);
		Test_FWS_cfgSetInputs(i, FWS_INP_CFG_SI_1, FWS_INP_CFG_SI_2, FWS_INP_CFG_SI_3, FWS_INP_CFG_SI_4, FWS_INP_CFG_SI_5);
	}
	SOSZ_clearSOSZ_SILoAlm(SI_1_to_8);

	FWS_init();
	for (i=FWS_SECTOR_1; i<=FWS_SECTOR_8; i++)
	{
		Test_FWS_verifyOutputs(i, FWS_STATE_STANDBY);
	}

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
}
void Test_FWS_multSectors_interlockTest_maxEight(void)
{
	enum FWS_Sector i;
	Test_FWS_multSectors_setup(8);
	for (i=FWS_SECTOR_1; i<=FWS_SECTOR_8; i++)
	{
		Test_FWS_verifyOutputs(i, FWS_STATE_NO_WATER);
	}
}
void Test_FWS_multSectors_interlockTest_twoOnly(void)
{
	enum FWS_Sector i;
	Test_FWS_multSectors_setup(2);
	for (i=FWS_SECTOR_1; i<=FWS_SECTOR_2; i++)
	{
		Test_FWS_verifyOutputs(i, FWS_STATE_NO_WATER);
	}
	for (i=FWS_SECTOR_3; i<=FWS_SECTOR_8; i++)
	{
		Test_FWS_verifyOutputs(i, FWS_STATE_STANDBY);
	}
}
void Test_FWS_outputs_FWSoutputDrivesPhysical(void)
{
// SO Not set to FWS Mode -- SO driven by SO Logic
	Test_FWS_loadCfgSimple();
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
	Test_SO_pulseOnOff_setup();
	SO_FWS_setSoMode(SO_T_SO, SO_OBJ_1, SO_MODE_SO);  // override normal SO_MODE_FWS
	SO_FWS_setSoMode(SO_T_SO, SO_OBJ_2, SO_MODE_SO);  // override normal SO_MODE_FWS

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_SO_pulseOnOff_cycle(1, PULSE_ON, PULSE_OFF);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);

	FWS_thread();
	Test_SO_pulseOnOff_cycle(1, PULSE_ON, PULSE_OFF);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);

	FWS_thread();
	Test_SO_pulseOnOff_cycle(1, PULSE_ON, PULSE_OFF);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);

	FWS_thread();
	Test_SO_pulseOnOff_end(STEADY_ON);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);

// SO set to FWS Mode -- SO driven by FWS
	Test_FWS_loadCfgSimple();
	Test_SO_pulseOnOff_setup();
	FWS_init(); // must run after SOSZ init...
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
//	SO_FWS_setSoMode(SO_T_SO, SO_OBJ_1, SO_MODE_FWS);
//	SO_FWS_setSoMode(SO_T_SO, SO_OBJ_2, SO_MODE_FWS);

	// Set alarm
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	Test_SO_pulseOnOff_cycle(1, IDLE_ACTIVE, IDLE_ACTIVE);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_1), SO_PHY_ON);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_2), SO_PHY_ON);

	FWS_thread();
	Test_SO_pulseOnOff_cycle(1, IDLE_ACTIVE, IDLE_ACTIVE);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_1), SO_PHY_ON);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_2), SO_PHY_ON);

	SO_FWS_setSoMode(SO_T_SO, SO_OBJ_2, SO_MODE_SO);
	FWS_thread();
	Test_SO_pulseOnOff_cycle(1, IDLE_ACTIVE, IDLE_ACTIVE);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_1), SO_PHY_ON);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_2), SO_PHY_OFF);

	SO_FWS_setSoMode(SO_T_SO, SO_OBJ_2, SO_MODE_FWS);
	FWS_thread();
	Test_SO_pulseOnOff_end(IDLE_ACTIVE);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_1), SO_PHY_ON);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_2), SO_PHY_ON);

	// Clear alarm
	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_INACTIVE);
	Test_SO_pulseOnOff_end(IDLE_ACTIVE);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_1), SO_PHY_ON);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_2), SO_PHY_ON);

	// Press Reset, clear SO 1
	/* Simulate press of RESET Button*/
	BTN_btnEvent_testSet(eBtnReset, evt_yes);
	FWS_thread();
	Test_SO_pulseOnOff_end(IDLE_ACTIVE);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_1), SO_PHY_OFF);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_SO, SO_OBJ_2), SO_PHY_OFF);

// SO Not set to FWS Mode -- SO driven by SO Logic
	Test_FWS_loadCfgSimple();
	Test_FWS_cfgSetOutputs(FWS_SECTOR_1, FWS_OUT_CFG_RL_1, FWS_OUT_CFG_SO_2, FWS_OUT_CFG_SO_3, FWS_OUT_CFG_SO_4, FWS_OUT_CFG_RL_1, FWS_OUT_CFG_RL_2, FWS_OUT_CFG_RL_3);
	FWS_init();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);
	Test_SO_pulseOnOff_setup();
	SO_FWS_setSoMode(SO_T_RL, SO_OBJ_1, SO_MODE_FWS);

	Test_FWS_setAlarmFixedCfg(FWS_T_SI, FWS_INP_DET_ZONE_1, FWS_ACTIVE);
	FWS_thread();
	SOSZ_thread(MODE_NORMAL);
	Test_verifyUint8(SOSZ_test_getActiveState(SO_T_RL, SO_OBJ_1), IDLE_ACTIVE);
	Test_verifyUint8(SO_getPhyDriverState(SO_T_RL, SO_OBJ_1), SO_PHY_ON);
//	Test_SO_pulseOnOff_cycle(1, PULSE_ON, PULSE_OFF);
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_NO_WATER);
}
void Test_FWS(void)
{
	Test_FWS_zeroAllFwsConfig();
	FWS_init();
//	Test_FWS_verifyInitial();
	Test_FWS_verifyOutputs(FWS_SECTOR_1, FWS_STATE_STANDBY);

//	Test_FWS_forceInputNoSI(); // this test requires decoupling the updateInputs function from the FWS_thread...

	// PASSING TESTS

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Standby to Active (via CheckTimer) tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_standbytoNoWater_cfgSimple();

	Test_FWS_standbyToPreRelease_simplePreReleaseOnly();
	Test_FWS_standbyToStartup_simpleStartupOnly();
	Test_FWS_standbyToDumpOn_simpleDumpOnOnly(0, 0);
	Test_FWS_standbyToFirstDumpOn_simpleDumpOnAndFirstDumpOnOnly(0, 0);
	Test_FWS_standbyToPreRelease_abortSetFirst_simplePreReleaseOnly();
	Test_FWS_standbyToPreRelease_mcpPreRelease();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Crosszone tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_crosszone_standbytoNoWater();
	Test_FWS_crosszone_setDet2ForceTriggerWithMCP_standbytoNoWater();
	Test_FWS_crosszoneAndPreRelease_standbyToPreRelease();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Lockoff tests --
	 * 	should lockoff be tested in all states?
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_lockoff_standbyToLockoff();
	Test_FWS_lockoff_removeLockoffAlmPresent_toNoWater();
	Test_FWS_lockoff_removeLockoffAlmClear_toStandby();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Cancel tests --
	 * 		- cancel input removed, state cancel to state waitForNextAlm or noWater
	 * 		- should cancel be tested in all states?
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_cancel_standbyToCancel();
	Test_FWS_cancel_removeCancel_resetAlmPresent_stayInCancel();
	Test_FWS_cancel_removeCancel_resetAlmClear_toStandby();
	Test_FWS_cancel_standbytoNoWaterToCancel();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS PreRelease tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_preRelease_countdown_toNoWater();
	Test_FWS_preRelease_verifyPreReleaseEnabledForZone1_notForZone2orMCP_standbyToPreRelease();
	Test_FWS_preRelease_verifyPreReleaseEnabledForZone2_notForZone1orMCP_standbyToPreRelease();
	Test_FWS_preRelease_verifyPreReleaseEnabledForMCP_notForZone1orZone2_standbyToPreRelease();
	Test_FWS_preRelease_verifyPreReleaseEnabledForZone1CrossZone_standbyToPreRelease();

	Test_FWS_preRelease_countdown_toDumpOn();
	Test_FWS_preRelease_abortInput_toAbort();
	Test_FWS_preRelease_inputsRtnNormalDuringPreRelease_completePreRelCountdownThentoNoWater_____Q__();
	Test_FWS_preRelease_mcpAlmDuring_exitPreReleaseImmediately_checkTimerstoNoWater();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Abort tests --
	 * 		- MCP - will exit any abort state and go call checkTimer
	 * 			?? What if alarm that initiated exit from standby was MCP??
	 * 		- when abort timer expired and abort input is released, inputs are evaluated
	 * 			- if inputs in alarm, then call checkTimer
	 * 			- if inputs not in alarm, then return to standby
	 * 		- cannot exit abort states until abort input is released
	 * 			exception: cancel input is enabled and activated
	 * 		- Abort input only has meaning during the PreRelease and Abort state
	 * 			-- should this be checked in every state?
	 * 			-- should I write an invariant in the code: if (state != PR && state != ABORT)   abortInput = INACTIVE
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_abort_abortHeldTillEndAlmPresent_toAbortWaitForReleased();
	Test_FWS_abort_abortHeldTillEndAlmClear_toAbortWaitForReleased();

	Test_FWS_abort_abortReleasedDuringCountDown_toAbortWaitTimer();
	Test_FWS_abort_mcpDuring_checkTimersNoOtherTimerCfg_toNoWater();

	Test_FWS_abortWaitForReleased_abortReleasedAlmPresent_checkTimersNoOtherTimerCfg_toNoWater();
	Test_FWS_abortWaitForReleased_abortReleasedAlmPresent_checkTimersStartupCfg_toStartup();
	Test_FWS_abortWaitForReleased_abortReleasedAlmPresent_checkTimersDumpOnCfg_toDumpOn();
	Test_FWS_abortWaitForReleased_abortReleasedAlmPresent_checkTimersFirstDumpOnCfg_toFirstDumpOn();
	Test_FWS_abortWaitForReleased_abortReleasedAlmClear_toStandby();
	Test_FWS_abortWaitForReleased_mcpDuring_checkTimersNoOtherTimerCfg_toNoWater();

	Test_FWS_abortTimer_countdownAlmPresent_checkTimersNoOtherTimerCfg_toNoWater();
	Test_FWS_abortTimer_countdownAlmClear_checkTimersNoOtherTimerCfg_toStandby();
	Test_FWS_abortTimer_mcpDuring_checkTimersNoOtherTimerCfg_toNoWater();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Startup tests --
	 * 		- once startup is entered, a release cannot be aborted (unless cancel is enabled and activated)
	 * 		- this means that inputs are no longer evaluated (except at end of release cycle)
	 * 		- an assumed precondition is that some inputs were active upon transition to Startup (or DumpOn or waitForNext)
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_startup_countdownAlmPresent_checkTimersNoOtherTimerCfg_toNoWater();
	Test_FWS_startup_countdownAlmClear_checkTimersNoOtherTimerCfg_toNoWater();
	Test_FWS_startup_countdownAlmPresent_checkTimersDumpOnCfg_toDumpOn();
	Test_FWS_startup_countdownAlmPresent_checkTimersFirstDumpOnCfg_toFirstDumpOn();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS DumpOn tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_dumpOn_countdownAlmPresent_toDumpOff();
	Test_FWS_dumpOn_countdownAlmPresent_toNoWater_dumpOffAndPauseZero();

	Test_FWS_dumpOnCycle_C1setZeroIsOne_countdownAlmPresent_toPause(0);
	Test_FWS_dumpOnCycle_C1setMaxIsMax_countdownAlmPresent_toPause();
	Test_FWS_dumpOnCycle_C1overMaxIsMax_countdownAlmPresent_toPause();
	Test_FWS_dumpOnCycle_C1setOneIsOne_countdownAlmPresent_toDumpOffToDumpOnNoWater();
	/* -------------------------------------------------------------------------------------------------------------
	 * FWS OneShot tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_dumpOn_oneShotDet1_det1LastSet_toPause();
	Test_FWS_dumpOn_oneShotDet1_det1NotLastSet_toDumpOff();
	Test_FWS_dumpOn_oneShotMCP_mcpNotLastSet_toDumpOff();
	Test_FWS_dumpOn_oneShotMCP_mcpLastSet_toPause();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS FirstDumpOn tests --
	 * 		What happens after a pause/reset cycle? Do we do first dump on again?
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_firstDumpOnCycle_countdownAlmPresent_toDumpOffToDumpOnToNoWater();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS DumpOff tests -- these tests are handled through dumpOnCycle
	 * -------------------------------------------------------------------------------------------------------------- */
	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Pause tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_pause_countdown_toResetOn(0);
	Test_FWS_pause_countdown_toNoWater_viaEndOfCycle_skipReset();
	Test_FWS_pause_countdown_toDumpOn_viaEndOfCycle_skipReset();
	Test_FWS_pause_countdown_toWaitForNext_viaEndOfCycle_skipReset();
	/* -------------------------------------------------------------------------------------------------------------
	 * FWS ResetOn tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_resetOn_countdown_toResetOff(0);

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS ResetOff tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_resetOff_countdown_toNoWater_viaEndOfCycle();
	Test_FWS_resetOff_countdown_toWaitForNext_viaEndOfCycle();
	Test_FWS_resetOff_countdown_toDumpOn_viaEndOfCycle();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS WaitForNextAlarm tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_waitForNextAlarm_newAlarm_toStartupSkipPreRelease_viaCheckTimer();
	Test_FWS_waitForNextAlarm_resetPressedAlmClear_toStandby();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS NoWater tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_noWater_newAlarm_stayInNoWater();
	Test_FWS_noWater_resetPressedAlmPresent_stayInNoWater();
	Test_FWS_noWater_resetPressedAlmClear_toStandby();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Input Triggers -- Verify Inputs other than Det1 work (Det2, MCP, extra) --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_det2();
	Test_FWS_mcp();
	Test_FWS_extraReleaseTest();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Inputs -- verify other configs
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_input_szLow();
	Test_FWS_input_siHigh();
	Test_FWS_input_szHigh();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Configuration tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_configuration();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Multiple Sector tests --
	 * 		Note: I "cheated" by putting a guard in FWS_init -- if (interlock == 0) then interlock = 1
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_multSectors_interlockTest_twoOnly();
	Test_FWS_multSectors_interlockTest_maxEight();

	/* -------------------------------------------------------------------------------------------------------------
	 * FWS Physical Layer tests --
	 * -------------------------------------------------------------------------------------------------------------- */
	Test_FWS_outputs_FWSoutputDrivesPhysical();

	// FAILING TESTS -- working on code

	// FAILING TESTS -- code not implemented


// unimplemented tests
#if 0
	Test_FWS_inputs_verifySI9toSI12();
	Test_FWS_inputs_verifySZ1toSZ8();
	Test_FWS_inputs_verifySZ9toSZ12();

	// Can any errors happen during startup, dumpOn, or dumpOff?
	// Can any errors happen during resetOn, resetOff or pause?
	// What if alarms lost or new alarms during the state?

	Test_FWS_multSectors_sectorsUsingSamePhyOutput();

	Test_FWS_oneShotTests();

#endif
	/*
	 * x cross zone -- use cfgSimple, add cross-zone --> only affects standby
	 * o inputs -- unspecified input always sets input to INACTIVE
	 * x Active FWS Sector - require at least one input (det1, det2, or mcp); require both hp and lp
	 * x interlock -- use cfgSimple, add interlock
	 * x one shot -- requires dumpOn to test
	 * 		What happens after one shot?
	 * o preRelease state
	 * 		x press abort goes to abort state (timer = timer + abortTimer)
	 * 		o if no abort and alarm triggers no longer active at end of state, go back to idle or check timers?
	 * x abort state
	 * 		x abort button held till end of abort timer, inputs in alarm - proceed to startup when abort released
	 * 		x abort button held till end of abort timer, inputs are normal - back to standby when abort released
	 * x waitForNextAlarm state
	 * 		This state presumes that their are no inputs in alarm (this is an entry criteria).
	 * 		x a new alarm causes immediate transition to Dump On state
	 * 		x pressing reset button - if inputs normal, go to standby
	 * x check timers -- variations of preRelease, startup, dumpOn,
	 * 		if      t.preRelease --> s.preRelease
	 * 		else if t.startup    --> s.startup
	 * 		else.if t.dumpOn	 --> s.dumpOn
	 * 		else                 --> s.waitForNextAlarm
	 * x normal cycle - c1 - after dumpOn/dumpOff; variations of c1, t.dumpOff, t.pause
	 * 		if (c1 != 0)
	 *			if (t.dumpOff) --> s.dumpOff
	 *			else --> s.noWater
	 *		else
	 *			if (t.pause) --> s.pause
	 *			else --> endOfCycle()
	 * x end_of_cycle() - c2 - after pause/reset; variations of c2, t.dumpOn,
	 * 		if (c2 !=0)
	 * 			if (sector_normal() != TRUE)
	 * 				if (t.dumpOn) --> s.dumpOn
	 * 			else --> s.waitForNextAlarm
	 *		else --> s.noWater
	 * x simple countdown states -- startup, dumpOn, dumpOff, pause, resetOn, resetOff -- can only be affected by cancel, (not effected by status change in det1, det2, mcp, lockoff,
	 * 		abort, extraRel; not affected by cfg settings for cross-zone, one-shot, interlock setting)
	 * o one shot --
	 * 		o does the last input really matter?
	 * 		o how many times can one shot happen?
	 * o first dump on
	 * 		o is this only for the first c2 cycle? Or does it apply to c2 cycle?
	 * o abort - verify it only has affect in preRelease and Abort (simulate press in every other state)
	 * o cancel
	 * 		x cancel state is pretty very similar to no water, except in cancel, all outputs are off
	 * 		x cancel is like lockoff, except cancel requires reset
	 * 		o verify cancel in every state
	 * o lockoff
	 * 		x lockoff is like cancel, but does not require a reset; after lockoff is released, if fws inputs in alarm, fws will immediately activate (checkTimers())
	 * 		o verify lockoff only works from standby
	 */
}
void Test_SI(void)
{
	BYTE Test_SICfg_use = 1;
  	Test_SI_SH_nonLatchNoTimer_idleToWaitForAck(Test_SICfg_use);  // passes
  	Test_SI_NS_latching_overrideAdcState_severalNStests(); // passes

	Test_SI_StatusFxn_doesNotDriveGlobLedAndRelay();
	Test_SI_SilentFxn_doesNotDriveBuzzerOrGlobalLedAndRelay();
//	Test_SI_SH_centCfg_setAlmMonitorSOtimers(Test_SICfg_use); // fails
//	Test_SI_SH_centCfg_SZ2xTest(Test_SICfg_use); // fails

	Test_SI_inputTypes();
}
void Test_testHarness (void)
{
///	Test_SI();

///	Test_SO();

///	Test_REL_resourceArray_requestRelay_requestTwice();

/*	BYTE ary [5] = 0, arz[5] = 0;
	memset(ary, 2, 5);
	memset(arz, 4, 5);
	memcpy(ary, arz, 5);*/
//	_OPT_IDECL   void   *memset(void *_mem, int _ch, size_t _n);
///	Test_GA();
	Test_FWS();

}
